[jQuery] Re: dynamically inserted droppable
Thanks, it works. However, it there any way I can design this more nicely so there won't be unnecessary code repetitions? It just feels a little odd to pass over all the options again. On Feb 9, 1:41 am, "Richard D. Worth" wrote: > After you add the element to the page, just call .droppable() on it. > > $('new user > group').appendTo('#container_usergroups').css('display', > 'none').fadeIn('slow').droppable(options); > > - Richard > > On Sat, Feb 7, 2009 at 12:20 PM, Chris wrote: > > > Hi, > > > I am relatively new to developing applications with both javascript > > and the jquery framework. What I can't figure out is what to do if I > > dynamically insert something on my page (imagine I click on a button > > to create a new div-container) and that div should then automatically > > become a droppable or something. > > > Right now, I have the following code loaded on the top of my site. > > This is not working when I dynamically load the div but of course is > > when I manually add that markup to the page. > > > $('.usergroup').droppable({ > >accept: function(draggable) { > >// imagine certain logic that will return true > >}, > >drop: function(event, ui) { > >// do something... > >} > > }); > > > $('#newgroup').live('click', function() { > >$('new user group').appendTo > > ('#container_usergroups').css('display', 'none').fadeIn('slow'); > > }); > > > How can I make that div actually be droppable / whatever I want it to > > be? > > > Thanks, > > Christian
[jQuery] Re: dynamically inserted droppable
After you add the element to the page, just call .droppable() on it. $('new user group').appendTo('#container_usergroups').css('display', 'none').fadeIn('slow').droppable(options); - Richard On Sat, Feb 7, 2009 at 12:20 PM, Chris wrote: > > Hi, > > I am relatively new to developing applications with both javascript > and the jquery framework. What I can't figure out is what to do if I > dynamically insert something on my page (imagine I click on a button > to create a new div-container) and that div should then automatically > become a droppable or something. > > Right now, I have the following code loaded on the top of my site. > This is not working when I dynamically load the div but of course is > when I manually add that markup to the page. > > $('.usergroup').droppable({ >accept: function(draggable) { >// imagine certain logic that will return true >}, >drop: function(event, ui) { >// do something... >} > }); > > > $('#newgroup').live('click', function() { >$('new user group').appendTo > ('#container_usergroups').css('display', 'none').fadeIn('slow'); > }); > > How can I make that div actually be droppable / whatever I want it to > be? > > Thanks, > Christian >
[jQuery] Re: dynamically inserted droppable
Nothing guys? Still couldn't figure it out on my own. Everything appreciated. On Feb 7, 6:20 pm, Chris wrote: > Hi, > > I am relatively new to developing applications with both javascript > and the jquery framework. What I can't figure out is what to do if I > dynamically insert something on my page (imagine I click on a button > to create a new div-container) and that div should then automatically > become a droppable or something. > > Right now, I have the following code loaded on the top of my site. > This is not working when I dynamically load the div but of course is > when I manually add that markup to the page. > > $('.usergroup').droppable({ > accept: function(draggable) { > // imagine certain logic that will return true > }, > drop: function(event, ui) { > // do something... > } > > }); > > $('#newgroup').live('click', function() { > $('new user group').appendTo > ('#container_usergroups').css('display', 'none').fadeIn('slow'); > > }); > > How can I make that div actually be droppable / whatever I want it to > be? > > Thanks, > Christian