Kendo 数据绑定中的动态 URL 或列表项的属性
我有两个菜单项,我试图使用 Kendo Jquery/MVVM 有条件地路由。 最初此值是在 data-href
标记中设置的,并且渲染 url 效果很好,但我需要更改此值以有条件地加载 url。这是一个列表项
.aspx
<li data-bind="attr: {invisible:bIsHuddles3FeatureEnabled, href: urlSource}">
<span>URL Option 1</span>
</li>
<br>
<li data-bind="attr: {invisible:bIsHuddles3FeatureEnabled, href: urlSource}">
<span class="nav-text">URL Option 2</span>
</li>
.ts
urlSource: function () {
let huddleURL = '';
if (check I want to perform is true) {
huddleURL = "/Application/URLOption1.aspx";
} else {
huddleURL = "/Application/URLOption2.aspx";
}
return huddleURL;
}
我没有将我路由到我期望的页面,而是重新路由到应用程序的主页。我还在 li
中使用 data-bind= "attr: {visible: anotherMethod, href: /Application/URLOption2.aspx}"
尝试过此操作,但收到错误消息 < code>li 元素不支持 href 绑定。任何对此的见解将不胜感激
I have two menu items that I am trying to route conditionally using Kendo Jquery/MVVM.
Initially this value was set in a data-href
tag and was rendering the url just fine, but I need to change this to conditionally load a url. This is a list item
.aspx
<li data-bind="attr: {invisible:bIsHuddles3FeatureEnabled, href: urlSource}">
<span>URL Option 1</span>
</li>
<br>
<li data-bind="attr: {invisible:bIsHuddles3FeatureEnabled, href: urlSource}">
<span class="nav-text">URL Option 2</span>
</li>
.ts
urlSource: function () {
let huddleURL = '';
if (check I want to perform is true) {
huddleURL = "/Application/URLOption1.aspx";
} else {
huddleURL = "/Application/URLOption2.aspx";
}
return huddleURL;
}
Instead of routing me to the page I expect, I am rerouted to the main page of the application. I also tried this using data-bind= "attr: {visible: anotherMethod, href: /Application/URLOption2.aspx}"
in the li
but received an error message The href binding is not supported by the li element
. Any insight into this would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是不是就加个那么简单?元素并对其进行绑定?
Is it as simple as adding an <a> element and having the binding on that?