Cannot get jquery ui functions to associate with dynamic elements.

5 views
Skip to first unread message

Smita Busar

unread,
Jul 9, 2013, 3:30:54 AM7/9/13
to node-...@googlegroups.com
OS = Win8, Node version = v0.6.2

I am trying to associate dynamically generated button elements:
[code simplified to fit on screen]
<button type="button" class="btn btn-primary btn-done" id="btn-file-done-2013-Feb-23" group="2013-Feb-23">Done</button>

with the following function:

//merge functions.
$(":button.btn-done").click(function() {
console.log('done clicked...');
});

The same piece of code works fine when i load the page up in a browser directly w\o going through node webkit. Am I missing something obvious or is this a known issue?


thanks,
Smita



Marc Torruella

unread,
Jul 9, 2013, 3:34:07 AM7/9/13
to node-...@googlegroups.com
does it work with jquery's live function?




--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Smita Busar

unread,
Jul 9, 2013, 4:03:49 AM7/9/13
to node-...@googlegroups.com
i am using ui 1.10.2 & live isn't supported from 1.9+. Are you suggesting I should try using live()?

Marc Torruella

unread,
Jul 9, 2013, 4:05:13 AM7/9/13
to node-...@googlegroups.com
yes, but not if it is deprecated, sorry did not know

Smita Busar

unread,
Jul 9, 2013, 4:09:37 AM7/9/13
to node-...@googlegroups.com
no worries. any other suggestions? i'm curious as to why it isn't working using nw. i guess it has something to do with the event propogation. maybe not evereything is wired in? any other suggestions\work-arounds?

Marc Torruella

unread,
Jul 9, 2013, 4:12:06 AM7/9/13
to node-...@googlegroups.com
what happens when you execute 

$(":button.btn-done").click(function() {
console.log('done clicked...');
});

 on console? does click start to work?

what does  $(":button.btn-done").length return?

that's the first i would check...

Smita Busar

unread,
Jul 9, 2013, 4:38:22 AM7/9/13
to node-...@googlegroups.com
thanks for your suggestions Marc. click() starts to work when i explicitly execute it from the console. Also, looks like one needs to use "on" instead of live() goign fwd. Even after integrating the same, it doesn't work for me. As you can imagine, i am trying to not go the 'ugly' route of explicitly calling the fn() in html code. I'll play around with this a bit more.

once again, thanks for your suggestions.

michae...@gmail.com

unread,
Jun 5, 2014, 2:52:15 AM6/5/14
to node-...@googlegroups.com
$(document).on('click', '.selector', function() {

});

Bastian KG

unread,
Jun 5, 2014, 5:53:10 AM6/5/14
to node-...@googlegroups.com
try just

iscelia...@gmail.com

unread,
Jun 5, 2014, 3:34:56 PM6/5/14
to node-...@googlegroups.com
Why do you not try this?

$("body").on("click",":button.btn-done",function() {
console.log('done clicked...');
});

this should allow use dynamically created elements.

super...@gmail.com

unread,
Jun 12, 2014, 9:24:26 AM6/12/14
to node-...@googlegroups.com

One more thing, in some context, in node-webkit u need to expecify "window.console.log("the text");"

That cases are when for example you are in a module via require (.js) instead of the html itself or a script included on it as normal.

I know is not related to jquery ui, is just an advice.


Reply all
Reply to author
Forward
0 new messages