Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make the show page work with realtime update and remove events

  • Loading branch information...
commit dd48d401b56b2636bc6f56d121cb072b3655a0e8 1 parent 4b85ae4
@Techwraith Techwraith authored
Showing with 18 additions and 7 deletions.
  1. +18 −7 templates/scaffold/realtime/views/ejs/show.html.ejs.ejs
View
25 templates/scaffold/realtime/views/ejs/show.html.ejs.ejs
@@ -18,14 +18,25 @@
<%% } -%>
<script type="text/javascript">
+$(function(){
-geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+ var pageId = window.location.pathname.split('/')[2];
-geddy.model.<%= names.constructor.singular %>.on('update', function (<%= names.property.singular %>){
- var properties = <%= names.property.singular %>.toData();
- for (var i in properties) {
- $('.'+i).text(properties[i]);
- }
-});
+ geddy.io.addListenersForModels(['<%= names.constructor.singular %>']);
+
+ geddy.model.<%= names.constructor.singular %>.on('update', function (<%= names.property.singular %>){
+ if (<%= names.property.singular %>.id == pageId) {
+ var properties = <%= names.property.singular %>.toData();
+ for (var i in properties) {
+ $('.'+i).text(properties[i]);
+ }
+ }
+ });
+ geddy.model.<%= names.constructor.singular %>.on('remove', function (id){
+ if (id == pageId) {
+ window.location = '/<%= names.property.plural %>';
+ }
+ });
+});
</script>
Please sign in to comment.
Something went wrong with that request. Please try again.