KnockoutJS: Tracking menu clicks

霸气de小男生 提交于 2019-12-02 04:04:50

Your issue is that your variable viewModel is defined in the jQuery ready function, so the functions in your data-binds can't see it, since it is not at the global scope. Even, doing a var viewModel = {} outside the $(function() { ... }); would work.

The way that you defined your click function looks good to me. Your visible logic though should use viewModel.menuActive() and viewModel.currentMenu() to access the values as they are in an expression.

Hope this helps. Would be happy to help further, if you get stuck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!