【问题标题】:Open actionsheet immediately fires data-action打开操作表立即触发数据操作
【发布时间】:2014-01-20 17:52:47
【问题描述】:

我有一个类似于以下代码的操作表:

<ul data-role="actionsheet" id="marketplace-actions" >
    <li><a href="#" data-action="getCategoriesByPrice(5)">$$$$$</a></li>
    <li><a href="#" data-action="getCategoriesByPrice(4)">$$$$</a></li>
    <li><a href="#" data-action="getCategoriesByPrice(3)">$$$</a></li>
    <li><a href="#" data-action="getCategoriesByPrice(2)">$$</a></li>
    <li><a href="#" data-action="getCategoriesByPrice(1)">$</a></li>
</ul>

操作表由标签条上的标签打开,如下所示:

<div id="marketplace-tabstrip" data-role="tabstrip" style="font-size:125%; vertical-align:top;">
    <a href="#marketplace-recent-view" data-icon="font-flash">Just Added</a>
    <a href="#marketplace-category-view" data-icon="font-tags">Select Category</a>
    <!-- this one --> <a data-rel="actionsheet" href="#marketplace-actions" data-icon="font-dollar">Select Price <span class="km-font-resize-full"/></a>
    <a href="#marketplace-sort-view" data-icon="font-sort-alt-up">Change Order</a>
    <a href="#marketplace-location-view" data-icon="font-location">Change Location</a>
</div>

点击动作时应该触发的函数是:

function getCategoriesByPrice(price) {
    console.log("function getCategoriesByPrice() called");
    console.log("filter Categories by: " + price);
}

我的问题是,当我单击 tabstrip 按钮时,无论当前选择的选项是默认还是最近选择的,都会触发该选定选项的数据操作事件。这是默认行为吗?这是我可以覆盖的吗?我宁愿操作表什么都不做,只有在我更改选择时才会触发。

【问题讨论】:

    标签: javascript kendo-ui kendo-mobile


    【解决方案1】:

    我最终不得不通过从数据操作函数调用中删除参数来解决这个问题,如下所示:

    <ul data-role="actionsheet" id="marketplace-actions" >
        <li><a href="#" data-action="getCategoriesByPrice_5">$$$$$</a></li>
        <li><a href="#" data-action="getCategoriesByPrice_4">$$$$</a></li>
        <li><a href="#" data-action="getCategoriesByPrice_3">$$$</a></li>
        <li><a href="#" data-action="getCategoriesByPrice_2">$$</a></li>
        <li><a href="#" data-action="getCategoriesByPrice_1">$</a></li>
    </ul>
    

    并像这样创建单独的函数:

    function getCategoriesByPrice_5() {
        getCategoriesByPrice(5);
    }
    
    function getCategoriesByPrice_4() {
        getCategoriesByPrice(4);
    }
    

    也许 Telerik 现在已经改变了这一点,但在当时,这是我设法得到一个操作表来做我想做的事情的唯一方法。

    【讨论】:

      猜你喜欢
      • 2014-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多