Kendo 数据绑定中的动态 URL 或列表项的属性

发布于 2025-01-16 11:58:40 字数 1014 浏览 2 评论 0原文

我有两个菜单项,我试图使用 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 技术交流群。

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

发布评论

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

评论(1

深海里的那抹蓝 2025-01-23 11:58:40

是不是就加个那么简单?元素并对其进行绑定?

<li>
    <a data-bind="attr: {href: urlSource}"><span>URL Option 1</span></a>
</li>

Is it as simple as adding an <a> element and having the binding on that?

<li>
    <a data-bind="attr: {href: urlSource}"><span>URL Option 1</span></a>
</li>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文