【问题标题】:Unable to make sammy js route work with knockoutjs无法使 sammy js 路由与 knockoutjs 一起工作
【发布时间】:2014-05-27 13:15:36
【问题描述】:

我正在构建一个 SPA,以此 article 为起点。 jsfiddle here

我正在尝试将此解决方案转换为基于此article 使用 sammyjs jsfiddlehere

我带着我的混搭小提琴here

我面临的问题是单击链接时 Sammyjs 配置未被调用。不知道我哪里错了。

Sammy(function () {

this.get('#:section', function () {
    //this.params.section-- need to see the section selected by using this 

alert(this.params.section);//currently this is not working

    //based on the selected section would like to update the selectedSection and apply the appropriate view models

    //also a
    //ko.applyBindings(settingsModel, document.getElementById("settings"));
    //ko.applyBindings(notificationsModel, document.getElementById("notifications"));            

});
}).run();

【问题讨论】:

  • 你还需要添加 jquery: jsfiddle.net/TBzA5 然后你的代码工作正常。
  • 感谢您发现错误。我在这里有点新人,为什么我的声誉下降了 2。
  • 有人否决了这个问题

标签: knockout.js sammy.js


【解决方案1】:

根据 nemesv 注释包含 jquery 后,代码运行良好。 再次非常感谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-19
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    相关资源
    最近更新 更多