【问题标题】:Sorting a list with jPList clicking a button使用 jPList 单击按钮对列表进行排序
【发布时间】:2014-12-18 12:24:54
【问题描述】:

我正在尝试使用这个 jPList 库对列表进行排序。
问题是该库使用我不喜欢的 select 选项来执行此操作。我正在尝试使用按钮来订购我的清单。
在我的 JsFiddle 上,您可以看到我创建的演示,我的列表更大,但类似:

http://jsfiddle.net/Danny182/wsauumra/3/

我正在使用函数 .html 在 html 中插入他们在this 页面上使用的代码来对列表进行排序。 如果我手动将其放入 #sos div 中,它可以工作,但是通过单击按钮来完成,而 .html 则不能。

有人可以帮我吗?

$('.sortName').click(function () {
    $('#sos').html('<div class="hidden" data-control-type="default-sort" data-control-name="sort" data-control-action="sort" data-path=".title" data-order="asc" data-type="text"> clicked </div>');
});

【问题讨论】:

    标签: javascript jquery html sorting


    【解决方案1】:

    已解决:

    使用此代码有效,我必须在单击按钮后调用该功能:

    http://jsfiddle.net/Danny182/wsauumra/4/

    $('#demo').jplist({
    itemsBox: '.list',
    itemPath: '.list-item',
    panelPath: '.jplist-panel'
    });
    
    $('.sortName').click(function () {
        $('#sos').html('<div class="hidden" data-control-type="default-sort" data-control-name="sort" data-control-action="sort" data-path=".title" data-order="asc" data-type="text"> clicked </div>');
    
    
    $('#demo').jplist({
        itemsBox: '.list',
        itemPath: '.list-item',
        panelPath: '.jplist-panel'
        });
    });
    

    【讨论】:

      【解决方案2】:

      $('#main_div').on('click',".sortName", function() {

      $('#sos').html('点击');

      });

      【讨论】:

        猜你喜欢
        • 2013-04-27
        • 1970-01-01
        • 2020-03-28
        • 1970-01-01
        • 2022-01-05
        • 2014-09-25
        • 1970-01-01
        • 1970-01-01
        • 2022-12-10
        相关资源
        最近更新 更多