Re: jQuery: firing a click event from a class instead of an ID
Byron, delegate is not depreciated in 1.7, it's still active as of 1.11, which is the version that I'm using. There are a couple of instances of deferred.is that are depreciated but not .delegate. http://api.jquery.com/category/deprecated/deprecated-1.7/ http://blog.jquery.com/2011/11/03/jquery-1-7-released/ On Fri, Mar 20, 2015 at 1:35 PM, Byron Mann wrote: > > .on() in jquery 1.7+ is probably what to use instead of delegate(). I only > say this as the documentation notates on() supercedes delegate(). And they > have a habit of deprecation in these instances. > > $(document).on(event, selector, function ) > > On Mar 20, 2015 1:08 PM, "Scott Stewart" > wrote: > > > > > > .delegate is what I was looking for > > > > > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360277 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: jQuery: firing a click event from a class instead of an ID
.on() in jquery 1.7+ is probably what to use instead of delegate(). I only say this as the documentation notates on() supercedes delegate(). And they have a habit of deprecation in these instances. $(document).on(event, selector, function ) On Mar 20, 2015 1:08 PM, "Scott Stewart" wrote: > > > .delegate is what I was looking for > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360276 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: jQuery: firing a click event from a class instead of an ID
.delegate is what I was looking for $("#pathList").delegate('.editPathway','click', function(){ var x = $(this).data("id"); $('#pathEditFrm').jqm({ modal:true, ajax:'index.cfm?action=loadPathEdit&id=' + x + '&nolayout', closeOnEsc: true }).jqmShow(); }); #pathList is the parent container and the form is injected in via $.load() (there's a data form above it, I want to reload the bottom each time a new record is added) On Fri, Mar 20, 2015 at 12:17 PM, Robert Harrison wrote: > > I think you need to add an event listener for the class: > > classname.addEventListener('click', myFunction, false); > > > Robert Harrison > Full Stack Developer > AIMG > rharri...@aimg.com > Main Office: 704-321-1234 ext.118 > Direct Line: 516-302-4345 > www.aimg.com > > > > -Original Message- > From: Scott Stewart [mailto:webmas...@sstwebworks.com] > Sent: Friday, March 20, 2015 12:13 PM > To: cf-talk > Subject: jQuery: firing a click event from a class instead of an ID > > > I have a button on a page with a class attached to it (several buttons > actually) shouldn't I be able to attach a jQuery click event to the buttons > using a class as a selector: > > $(".editPathway").click(function(){ > var x = $(this).data("id"); > $('#pathEditFrm').jqm({ > modal:true, > ajax:'index.cfm?action=loadPathEdit&id=' + x + '&nolayout', > closeOnEsc: true > }).jqmShow(); > }); > > > a variation on this code fires just fine from an ID selector.. but won't > fire at all from a class. > > Thanks in advance > > -- > -- > Scott Stewart > Adobe Certified Instructor, ColdFusion 8 & 9 Adobe Certified Expert, > ColdFusion 8 & 9 > > Blog: http://www.sstwebworks.com > Email: webmas...@sstwebworks.com > > > > > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360275 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: jQuery: firing a click event from a class instead of an ID
I think you need to add an event listener for the class: classname.addEventListener('click', myFunction, false); Robert Harrison Full Stack Developer AIMG rharri...@aimg.com Main Office: 704-321-1234 ext.118 Direct Line: 516-302-4345 www.aimg.com -Original Message- From: Scott Stewart [mailto:webmas...@sstwebworks.com] Sent: Friday, March 20, 2015 12:13 PM To: cf-talk Subject: jQuery: firing a click event from a class instead of an ID I have a button on a page with a class attached to it (several buttons actually) shouldn't I be able to attach a jQuery click event to the buttons using a class as a selector: $(".editPathway").click(function(){ var x = $(this).data("id"); $('#pathEditFrm').jqm({ modal:true, ajax:'index.cfm?action=loadPathEdit&id=' + x + '&nolayout', closeOnEsc: true }).jqmShow(); }); a variation on this code fires just fine from an ID selector.. but won't fire at all from a class. Thanks in advance -- -- Scott Stewart Adobe Certified Instructor, ColdFusion 8 & 9 Adobe Certified Expert, ColdFusion 8 & 9 Blog: http://www.sstwebworks.com Email: webmas...@sstwebworks.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360273 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm