Ajax link actions?
Ajax link actions?
I think this is a simple problem but I cannot work it out.
When an ajax page is loaded into the #ajax div the links are now longer triggered.
I think this is because the document is loaded and the function is run. When the new information comes into the page it isn't in the same scope as the click function. Is this correct? Is there a work around?
- function pageload(hash) {
- if(hash) {
- $.ajax({
- url: "index.php?p="+hash+"&logo=0",
- cache: false,
- success: function(html){
- $("#ajax").html(html);
- }
- });
- }
- }
- $(document).ready(function(){
- $.historyInit(pageload, "index.php");
- // set onlick event for buttons
- $("a").click(function(){alert('click');
- if (strpos($(this).attr('href'), 'index.php') !== false) {
- var hash = idToPath($(this).attr('href'));
- $.historyLoad(hash);
- return false;
- }
- });
- });