sIFR not working with prototype AJAX page load

2019-08-31 06:16发布

I have a website with two pages. A and B. When you click on a link in page A, it will uses the Prototype Ajax.Updater() to load the link page (page B) into a div on the page (Page A).

When page B loads into page A, the sIFR replacements are not working and the tag inner text is not even showing.

I have tried doing a sIFR.redraw() when the page has loaded into the div, with no success.

When i view page B in the browser by itself, it works perfectly.

Is it possible to insert HTML into a DIV tag on a page using AJAX and have the sIFR display properly?

4条回答
祖国的老花朵
2楼-- · 2019-08-31 06:28

I would imagine that you probably need to re-initialise sIFR within the onComplete callback of Ajax.Updater

查看更多
劳资没心,怎么记你
3楼-- · 2019-08-31 06:37

You could put this snippet in your html code:

<script type="text/javascript">
    function pageLoad(sender, args) {
       sIFR.replace(font, { selector: '#content h2' });
    }
</script>

It will run the sIFR replacements each time the page reloads. This is on normal PostBack and Ajax postbacks. Make sure you have included a ScriptManager instance on your page.

查看更多
再贱就再见
4楼-- · 2019-08-31 06:46

mathijsuitmegen: Your solution worked perfectly on an application I'm using where the ScriptManager was already in use.

Infact, The function was simply slotted into my sifr-config.js file and worked perfectly meaning my HTML wasn't cluttered.

查看更多
可以哭但决不认输i
5楼-- · 2019-08-31 06:51

This is the way I ended up doing this

new Ajax.Updater('content', url, {
  onComplete:function(){
     sIFR.replace(font, {
        selector: '#content h2'
     });
  }
});
查看更多
登录 后发表回答