0

page-one.php contains such jquery

$.post("___for_ajax_process.php", data_to_send_ajax_post, function(data_edit_content) {
$('#show_result').html(data_edit_content);
});

in #show_result i see content from ___for_ajax_process.php

Rendered content contains many checkboxes and want to create check all. check all is named draft_check_all.

At first want to check what happens if I click the checkbox.

$("#draft_check_all").click(function(){
alert ( 'click test' );
});

And I do not see alert ( 'click test' ); No popup at all.

Then View source and I do not see source code for content rendered by ___for_ajax_process.php

As understand in such way can not apply jquery to content from ___for_ajax_process.php? What if place $("#draft_check_all").click(function(){ in ___for_ajax_process.php? Are there any solutions for such situation?

Solution

placed jquery in external php and all works!

Andris
  • 1,434
  • 1
  • 19
  • 34

1 Answers1

0

A better solution would be event delegation.

$('#show_result').on('click', '#draft_check_all', function () {
  ... 
});
Bill Criswell
  • 32,161
  • 7
  • 75
  • 66