开发者

insert content after jquery redirect

开发者 https://www.devze.com 2023-03-22 17:31 出处:网络
I would like redirect to a new page and insert content into that page when the new page is loaded all from rails js.erb file.

I would like redirect to a new page and insert content into that page when the new page is loaded all from rails js.erb file.

Here is the success.js.erb file:

window.location = "<%=escape_javascript(board_path(@board)) %>";
$(function () {
$('#BtnBoxGreeting').after($("<%= escape_javascript(image_tag 'blanksla开发者_JS百科te-1.png', :width => '429', :height => '103', :alt => 'Blankslate 1', :id => 'blankslate-1' )%>"));
});

This does not work as I need some kind of callback function that tells me when the redirected page has loaded.

Anyone help me with this?

Thanks


This will never work. The code after setting window.location will never run. You need to re-work your code so that the appropriate jQuery is included on the new page and is run at the appropriate time (perhaps $(document).ready()).

If you are trying to update just a portion of the page, check out $.ajax. Using that function you could request new HTML and update existing content on the page.


You have to basically write code on the redirected page load event using $(document).ready(). It is not at all possible what you want.

0

精彩评论

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

关注公众号