我们正在从jQuery阿基西迁移到History.js。Ajaxy拥有智能的表单管理。有谁有如何集成History.js来处理表单的示例吗?
发布于 2012-06-12 14:17:51
History.js本质上是一个跨浏览器的垫片,允许您使用HTML5历史API,而它没有专门提供任何内置的表单管理逻辑。因此,如果您想使用它来管理表单状态,您必须手动将历史条目添加到浏览器历史对象中,如下所示:
// If the History.js plugin has been included on the page
if(window.History) {
// Adds a new state and url to the browser history object
// Eg. If your page was index.html... it becomes index.html?someState
window.History.pushState(null, $(this).attr("data-href"), "?someState");
}如果您有一些需要在发生状态更改时发生的自定义逻辑,您可以这样做:
// If the History.js plugin has been included on the page
if(window.History) {
// Binds to the StateChange Event
window.History.Adapter.bind(window,'statechange',function() {
// Do something
});
}有关History.js的更多信息,请访问History.js github页面
https://stackoverflow.com/questions/6496435
复制相似问题