获取可排序jQuery中的拖动列表的ID

时间:2018-06-09 14:57:54

标签: jquery list jquery-ui-sortable

我有这个HTML代码。此代码列出了数据库中的每个项目

<table id="pricing-list-container">
                                    {% for list in list %}
                                    <tr class="pricing-list-item pattern">
                                        <td>
                                            <div style="display: none" id="fav_id">{{ list.pk }}</div>
                                            <div style="display: none" id="dep_id">{{ list.department.pk }}</div>
                                            <div class="fm-move"><i class="sl sl-icon-cursor-move"></i></div>
                                            <div class="col-md-1"><input type="text" id="order" placeholder="{{ list.order }}" readonly/></div>
                                            <div class="fm-input pricing-ingredients"><input type="text" placeholder="{{ list.department.get_name }}" readonly/></div>
                                            <div class="fm-input pricing-name"><input type="text" placeholder="{{ list.department.university.get_name }}" readonly/></div>
                                            <div class="fm-close"><a class="delete" onclick="delete_favorite({{ list.pk }}, this)"><i class="fa fa-remove"></i></a></div>
                                        </td>
                                    </tr>
                                 {% endfor %}
                                </table>

我想获得拖动元素的#fav_id和#dep_id?

这里是js代码

$('table#pricing-list-container tbody').sortable({
        forcePlaceholderSize: true,
        forceHelperSize: false,
        placeholder : 'sortableHelper',
        zIndex: 999990,
        opacity: 0.6,
        tolerance: "pointer",
        start: function(e, ui ){
             ui.placeholder.height(ui.helper.outerHeight());
        },
        stop: function(event, ui) {
          var fav_id = $('#fav_id').text();
            var positon = ui.item.index();
            var dep = $('#dep_id').text();
            var url = "/api/v1/dep-favorite/"+fav_id+"/";

}

感谢您的帮助:)

0 个答案:

没有答案