开发者

execute javascript on every reload - ruby on rails

开发者 https://www.devze.com 2023-02-07 12:58 出处:网络
I am reloading partial using ajax this way: new Ajax.PeriodicalUpdater(\'content\', \'/shouts/update.js\', { method: \'get\', frequency: 1});

I am reloading partial using ajax this way:

new Ajax.PeriodicalUpdater('content', '/shouts/update.js', { method: 'get', frequency: 1});

The reload is working great.

I added this javascrip开发者_StackOverflowt code to update.js to make the partial content fade:

$('content').fade({ duration: 3.0, from: 0, to: 1 });

And the problem is that nothing happens (the content doesn't fade).

What do you think is the problem?


I think the problem is that there is no fade function in JQuery... Try fadeTo

$('content').fadeTo(3000, 0);

also there is the function fadeToggle(). There you have a simple switch :)

UPDATE: thought it is was jquery... within Ajax.PeriodicalUpdater you can set the parameter evalScripts to true then the script will be available... http://api.prototypejs.org/ajax/Ajax/Updater/

0

精彩评论

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