javascript - Jquery run function after append -
i have table append table data. part of data checkbox. need check box if variable (inspectfall) has 1 (checked). below code works seems messy .each() call. there different way? remember nothing clicked, no can find triggered (load, blur, etc). calls function check box. thanks!
.append($('<td>').addclass('smallbox').append($('<input>', {'class': 'centertext', 'name': 'inspectfall', 'type': 'checkbox'}).each( function() { checkboxes($(this), inspectfall); } )))
what can pass object checkboxes() function this:
.append($('<td>').addclass('smallbox').append ($('<input>', checkboxes({'class': 'centertext', 'name': 'inspectfall', 'type': 'checkbox'})))) and in function can extend , return object if inspectfall has 1 this:
function checkboxes(obj) { return inspectfall == 1 ? $.extend(obj,{ "checked" : "checked" }): obj; } or if need inspectfall variable passed parameter add function call this:
.append($('<td>').addclass('smallbox').append ($('<input>', checkboxes({'class': 'centertext', 'name': 'inspectfall', 'type': 'checkbox'}, inspectfall)))) and function:
function checkboxes(obj, inspectfall) { return inspectfall == 1 ? $.extend(obj,{ "checked" : "checked" }): obj; }
Comments
Post a Comment