jquery. $.post shows content of php file. Click on button in the php content start function defined in main file -


for example file main.php

here on document ready function includes content of php file (named include.php).

this content of main.php

(function(){   $.post("include.php", function(show_some_content) {   $('#id_show_some_conent').html(show_some_content);   }); })(); 

also jquery function

$(".click_to_test").click(function(){ alert('.click_to_test clicked.');  }); 

and html

<div id="id_show_some_conent"></div> 

as result in id_show_some_conent contains content of include.php

include.php contains

echo '<button id="some_id" class="click_to_test"> click</button>'; 

so on document ready see button click. expect, if click on button, alert('.click_to_test clicked.');. no, not work.

if in include.php paste $(".click_to_test").click(function(){ works. how work if $(".click_to_test").click(function(){ in main.php?

you can try binding click event within $.post:

(function(){       $.post("include.php", function(show_some_content) {       $('#id_show_some_conent').html(show_some_content);       $(".click_to_test").bind('click',function(){           alert('.click_to_test clicked.');           });       });      })(); 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -