redo selecting items in gridftp
authorMaciej Tronowski <mtro@man.poznan.pl>
Thu, 16 Apr 2015 14:41:05 +0000 (16:41 +0200)
committerMaciej Tronowski <mtro@man.poznan.pl>
Thu, 16 Apr 2015 14:41:05 +0000 (16:41 +0200)
filex/static/filex/filex.js
filex/templates/filex/source.js.html

index 396064e..18d78d4 100644 (file)
@@ -126,7 +126,7 @@ $(function(){
         initialize: function(options) {
             this.view = options.view;
 
-            this.listenTo(this.model, 'change', this.render);
+            this.listenTo(this.model, 'change:checked', this.toggleChecked);
             this.listenTo(this.model, 'remove', this.remove);
             this.listenTo(this.model, 'hidden', this.toggleHidden);
         },
@@ -156,6 +156,11 @@ $(function(){
             this.$el.toggleClass('hidden', this.model.isHidden() && !this.view.showHidden());
         },
 
+        toggleChecked: function(obj, value) {
+            this.$el.toggleClass('active', value);
+            this.$el.find('input[type="checkbox"]').prop('checked', value);
+        },
+
         click: function(e) {
             if (e.target.className == 'link') {
                 if (this.model.isDir()) {
index 18cc281..311acb7 100644 (file)
@@ -19,7 +19,7 @@
 <script type="text/template" id="dir-template">
     <td class="text-center">
         <label for="dir-<%= cid %>" class="sr-only">Zaznacz katalog <%= name %></label>
-        <input id="dir-<%= cid %>" type="checkbox" autocomplete="off" <%= checked ? 'checked="checked"' : '' %>>
+        <input id="dir-<%= cid %>" type="checkbox" autocomplete="off">
     </td>
     <td class="text-center"><span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span></td>
     <td><a class="link" href="#"><%= name %></a></td>
@@ -30,7 +30,7 @@
 <script type="text/template" id="file-template">
     <td class="text-center">
         <label for="file-<%= cid %>" class="sr-only">Zaznacz plik <%= name %></label>
-        <input id="file-<%= cid %>" type="checkbox" autocomplete="off" <%= checked ? 'checked="checked"' : '' %>>
+        <input id="file-<%= cid %>" type="checkbox" autocomplete="off">
     </td>
     <td class="text-center"><span class="glyphicon glyphicon-file" aria-hidden="true"></span></td>
     <td>