与 jQuery superfish 一起使用的快速 Javascript 模板引擎?

发布于 2024-11-30 09:33:24 字数 570 浏览 5 评论 0原文

我有一个具有非常标准布局的项目,所以我怀疑这是一个常见问题:

<body>
HEADER-CONTAINER DIV - includes superfish jQuery menu plugin but am open to other menu options if necessary.
CONTENT-CONTAINER DIV - depending on the page, contains several other jQuery plugins, HTML, javaScript, etc.
FOOTER-CONTAINER DIV
</body>

我正在寻找一种优雅且性能良好的方法来让 superfish 菜单单击加载包含新内容的 CONTENT-CONTAINER DIV。内容包含 HTML 和 JavaScript。我还希望解决方案能够更改 URL,这样如果有人稍后返回到 /my/page,它将重新加载到正确的位置(类似于我对 Backbone.Router 的理解)。

有什么建议吗?如果可能,请提供指向加载到 div 示例并运行加载中包含的任何 javaScript 的页面的链接。

I have a project with a very standard layout so I suspect this is a common problem:

<body>
HEADER-CONTAINER DIV - includes superfish jQuery menu plugin but am open to other menu options if necessary.
CONTENT-CONTAINER DIV - depending on the page, contains several other jQuery plugins, HTML, javaScript, etc.
FOOTER-CONTAINER DIV
</body>

I'm looking for a elegant and well performing way to have a superfish menu click load the CONTENT-CONTAINER DIV with new content. The content contains both HTML and javaScript. I also want the solution to change the URL so if someone returns later to /my/page it will reload to the correct location (similar my understanding of Backbone.Router).

Any suggestions? If possible, please provide a link to a page loading into a div example and running any javaScript included in the load.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乞讨 2024-12-07 09:33:24

无论是否超级鱼,这都不是问题。每当您将 html 添加到页面时,浏览器都会执行任何 javascript 或加载此新 html 片段将包含的任何 javascript 文件。

因此,当您单击菜单时,加载(或生成)新的 html 并将内容 div 替换为新内容,浏览器将执行脚本。

您必须重新绑定新插入内容上的所有事件,因为 jQuery 将失去对它的跟踪。

Superfish or not this is not really a problem. Whenever you add html to the page the browser will execute any javascript or load any javascript file this new html snippet will contain.

So when you click on your menu, you load (or generate) new html and replace your content div with this new content, the browser will execute the scripts.

You will have to rebind all events on that newly inserted content because jQuery will loose track of that.

空城旧梦 2024-12-07 09:33:24

我四处搜索,发现了一个不错的例子,展示了如何获取任何 #url 并重新加载 div。示例位于 http://thomasdavis.github.com/examples/restful-app/

I searched around and found the a decent example that shows how to take any #url and reload a div. Example found at http://thomasdavis.github.com/examples/restful-app/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文