Reputation: 149
I have a checkbox with id #cond99
; it's loaded form ajax, and that's working okay but I want to add an action and it's not working. Can anyone help me?
jQuery = window.parent.jQuery;
jQuery(document).ready(function ()
{
jQuery('input.styled').iCheck(
{
checkboxClass: 'icheckbox_minimal-orange',
radioClass: 'iradio_minimal-orange',
increaseArea: '40%' // optional
});
jQuery('input.styled').iCheck('update');
jQuery("#cond999").bind("change", function ()
{
jQuery('#conditions_more').toggle();
});
});
Upvotes: 0
Views: 1731
Reputation: 5625
If you're inserting your #cond999 element as an Ajax, it might not be available when document.ready event fires, and therefore, you cant bind anything to it.
You might consider binding this event at a callback of an Ajax request that inserts the checkbox into the code.
Upvotes: 0
Reputation: 44740
If it's loaded dynamically you can use event delegation -
jQuery(document).on("change","#cond999", function () {
jQuery('#conditions_more').toggle();
});
Upvotes: 1
Reputation: 7139
This should work:
jQuery(document).on('change', '#cond999', function () {
jQuery('#conditions_more').toggle();
});
Upvotes: 1