Commits

Mark Lavin  committed 878e2c9

Make icons configurable and add bind function.

  • Participants
  • Parent commits f7ef984

Comments (0)

Files changed (1)

File selectable/static/js/jquery.dj.selectable.js

 (function($) {
 	$.widget("ui.djselectable", {
+
+        options: {
+            removeIcon: "ui-icon-close",
+            comboboxIcon: "ui-icon-triangle-1-s"
+        },
         
         _initDeck: function(hiddenInputs) {
             var self = this;
         },
 
         _addDeckItem: function(input) {
+            var self = this;
             $('<li>')
             .text($(input).attr('title'))
             .addClass('selectable-deck-item')
                     $('<button>')
                     .button({
                         icons: {
-                            primary: "ui-icon-close"
+                            primary: self.options.removeIcon
                         },
                         text: false
                     })
                     .click(function() {
                         $(input).remove();
                         $(this).closest('li').remove();
+                        return false;
                     })
                 )
             );
                 .insertAfter($(input))
                 .button({
                     icons: {
-                        primary: "ui-icon-triangle-1-s"
+                        primary: self.options.comboboxIcon
                     },
                     text: false
                 })
 	});
 })(jQuery);
 
-$(document).ready(function() {
-    $(":input[data-selectable-type=text]").djselectable();
-    $(":input[data-selectable-type=combobox]").djselectable();
-    $(":input[data-selectable-type=hidden]").each(function(i, elem) {
+function bindSelectables(context) {
+    $(":input[data-selectable-type=text]", context).djselectable();
+    $(":input[data-selectable-type=combobox]", context).djselectable();
+    $(":input[data-selectable-type=hidden]", context).each(function(i, elem) {
         var hiddenName = $(elem).attr('name');
         var textName = hiddenName.replace('_1', '_0');
         $(":input[name=" + textName + "][data-selectable-url]").bind("autocompletechange", function(event, ui) {
             }
         });
     });
+}
+
+$(document).ready(function() {
+    bindSelectables('body');
 });