$.click not firing on checkbox, in Chrome with JQuery 1.9.1 -
the click event not seem firing on checkbox in block of in-memory html. fire button not checkbox.
here's fiddle: http://jsfiddle.net/x2en3/18/
and code:
fired .trigger(): fired .click():
var working = $('<div><input type="checkbox" id="mybox"/><button id="mybutton"/><div>'), checkbox = working.find('#mybox'), button = working.find('#mybutton'), stage; function boxclicked() {$('#' + stage).append('--checkbox');} function buttonclicked() {$('#' + stage).append('--button');} working.delegate('#mybox', {click: boxclicked}); working.delegate('#mybutton', {click: buttonclicked}); stage = 'trigger'; checkbox.trigger('click'); button.trigger('click'); stage = 'click'; checkbox.click(); button.click();
this happening chrome , jquery 1.9.1. firefox/ie 9 , previous versions of jquery work fine.
any appreciated.
from jquery.com
http://api.jquery.com/delegate/
as of jquery 1.7, .delegate() has been superseded .on() method. earlier versions, however, remains effective means use event delegation. more information on event binding , delegation in .on() method. in general, these equivalent templates 2 methods:
try using on
method
var $checkbox = $("<input>", { type: "checkbox", id: "mybox" }); var $button = $("<button>", { type: "checkbox", id: "mybutton" }); var $container = $("<div>"); $container.append($checkbox); $container.append($button); $("body").append($container); $container.on("click", "#mybox", getcheckboxstatus); $container.on("click", "#mybutton", getbuttonstatus); function getcheckboxstatus() { $('#chckboxverify').append('yes'); } function getbuttonstatus() { $('#buttonverify').append('yes'); } $checkbox.click(); $button.click();
working example: http://jsfiddle.net/hunter/x2en3/22/
Comments
Post a Comment