php - Jquery: Building navigation including page inside body -


i builded home page (index.php) navigation bar, can click on 1 of available links (anchors). selecting 1 link new body loaded inside page (index.php) contains code:

<script type="text/javascript">   $(document).ready(function(){     $('#myselector a').click(function(e) {           var url = $(this).attr('href');           $('#body').load(url);           e.preventdefault();       });   }); 

this works good.

but, after loading new page page1.php inside body of index.php have trouble:

my page1.php contains form, , after submission need reload index.php page2.php inside. how can perfrom this?

note: edit question: if think clear can upvote plese? (i banned question , can't post other question)

in order catch events nodes inserted @ later point need use event-delegation, example this:

$("body").on("click", "a", function(e){     var url = $(this).attr('href');     e.preventdefault();      $('#body').load(url); }); 

this way every click on link, childnode of body cause eventhandler fire. if not want target links, specific ones can adding class them , selector.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -