简体   繁体   English

如何在页面之间共享jQuery脚本?

[英]How do I share jQuery script between pages?

what is the best way to share jQuery code between pages? 在页面之间共享jQuery代码的最佳方法是什么? this is the situation: 这是情况:

-------SITUATION--------- - - - -情况 - - - - -

I have several different pages that goes this way (pseudo code) 我有几个这样的不同页面(伪代码)

 <% render "content/link" , collection => required_links %>

In the "content/link" partial 在“内容/链接”部分

 <div class="element_to_be_changed"/>

Currently in EVERY PAGE that renders the partial, i call 目前在每个页面的部分呈现,我打电话

 jQuery.('.element_to_be_changed')... effect that i want...

This strikes me as unscalable, but i am not sure what is the best way to handle it. 这使我感到无法扩展,但是我不确定什么是最好的处理方式。 anyone has any ideas? 有人有什么想法吗?

如果每个页面上的内容完全相同,则将其放在外部脚本中,并将脚本包括在使用它的页面中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM