开发者

jquery - Is it possible to reload external div from internal code?

I have a code

<div id="content"></div>

I load into this content my Ajax content using load().

Now is it possible that from press on a button that is in this external ajax code I would reaload the content ID? It doesn't work and I think that is because this ID is external to the ajax code, it is not inside it.

I want it you press a button in the ajax external page code that the inside of would be reloaded again, because a press of a button should reload everything inside id=content.

Is that possible somehow?

Edit: my code on page1 that has id=content:

开发者_运维技巧$(document).ready(function() {

$('.edit').bind('click', function(event) {
    event.preventDefault();
    link=$(this).attr("href");
    $('#content').load(link);

});

On the ajax side that is loaded with this jquery code (let's say page2 that is loaded inside page1) I was using the same function. The preventDefault is executed but of course the #content is not changed as it is not part of the page2 but part of page1.

UPDATE: Thank you all, live was needed instead of bind. I didn't know the ajax part of the page can see "outside" of it's own code. So in fact it has access to the whole page, the html and the ajax HTML inside the div.


I'm not 100% sure but I think you're referring to binding an action to 'live' such as

$('.reload').live('click',function(){

//some actions
});

This "live" binding tells the page that any element that is either present at page render time OR loaded afterwards that has the class of reload when clicked needs to perform some action

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜