I've just started using jQuery and the really nice Interface plugin and
found that I was needing to call a function when something was de-selected
using the Selectable plugin.

As a quick hack, I've added a few lines to the iselect.js code, but would
love to see this integrated properly into the core plugin.

First, I changed the following code:

   this.f = {
               a : o.accept,
               o : o.opacity ? parseFloat(o.opacity) : false,
               sc : o.selectedclass ? o.selectedclass : false,
               hc : o.helperclass ? o.helperclass : false,
               onselect : o.onselect ? o.onselect : false
           };

to include an "ondeselect" option:

   this.f = {
               a : o.accept,
               o : o.opacity ? parseFloat(o.opacity) : false,
               sc : o.selectedclass ? o.selectedclass : false,
               hc : o.helperclass ? o.helperclass : false,
               onselect : o.onselect ? o.onselect : false,
               ondeselect : o.ondeselect ? o.ondeselect : false
           };

Then I modified this:

   if (jQuery.selectedone == true && this.f.onselect) {
       this.f.onselect(jQuery.Selectserialize(jQuery.attr(this,'id')));
   }

to:

if (jQuery.selectedone == true && this.f.onselect) {
       this.f.onselect(jQuery.Selectserialize(jQuery.attr(this,'id')));
   }
   else
   {
       this.f.ondeselect();
   }


After doing that, it's possible to call the selectable plugin with something
like this:

   <script type="text/javascript">
   $('#content').Selectable(
   {
       accept    : 'selectable',
       opacity : 0.2,
       selectedclass: 'selecteditem',
       helperclass: 'selecthelper',
       onselect: function(serial)
       {
           var selected = serial.hash;
           alert(selected);
       },
       ondeselect: function()
       {
           alert("deselecting");
       }
   }
   );
   </script>

and it works great!

just thought others might be interested.. thanks again for a really awesome
set of plugins!
-jason

--
jason schleifer
ah-ni-may-tor | weirdo
http://jonhandhisdog.com/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to