I am new to jQuery and an intermediate JS developer (I usually see how
things work but don't always understand why).  I encountered a
probable bug with the droppable 'accept' option.

The API provides the following details for getting/setting the option:

---CUT--
Initialize a droppable with the accept option specified.

    $('.selector').droppable({ accept: '.special' });

Get or set the accept option, after init.

    //getter
    var accept = $('.selector').droppable('option', 'accept');
    //setter
    $('.selector').droppable('option', 'accept', '.special');
--CUT--

The accept option works properly as a configuration option as
demonstrated in the UI dropppable example Accepted-elements (http://
jqueryui.com/demos/droppable/#accepted-elements).

        $("#droppable").droppable({
                accept: '#draggable',
                activeClass: 'ui-state-hover',
                hoverClass: 'ui-state-active',
                drop: function(event, ui) {
                        
$(this).addClass('ui-state-highlight').find('p').html('Dropped!');
                }
        });

But if I attempt to set it after initialization, like below, it
fails.  I tested all of the available options and this is the only one
that fails.

        $("#droppable")
                .droppable('option', 'accept', '.special')
                .droppable('option', 'activeClass', '.ui-state-highlight')
                .droppable('option', 'addClasses', false)
                .droppable('option', 'greedy', true)
                .droppable('option', 'hoverClass', 'drophover')
                .droppable('option', 'scope', 'tasks')
                .droppable('option', 'tolerance', 'fit');

I poked around and discovered that when it is initialized the option
is set as a string option (accept='.special').  After I call the
setter function it is no longer a string but is now a function and get
an error on line 54 of ui.droppable.js - accept is not defined.

50 _setData: function(key, value) {
51
52      if(key == 'accept') {
53              this.options.accept = value && $.isFunction(value) ? value :
function(d) {
54                      return d.is(accept);   // error - accept is not defined
55              };
56      } else {
57              $.widget.prototype._setData.apply(this, arguments);
58      }
59
60 },


I can open a ticket for this if you would like.  But I am also curious
of what is going on.  I have been poking around for a while and not
sure what it is. Be patient with me as I continue to learn JS.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to