小编Jul*_* G.的帖子

可扩展行的可排序表

我是一个jquery/rails新手,我在使用.sortable()时遇到了麻烦.我有可扩展的行,我似乎无法获得正确的代码,以隐藏行,即子行,坚持可见,即父行.相关的JS代码:

(function($){
    $.fn.jSortable = function(){


    var element = this;

    var fixHelper = function(e, ui) {
        ui.children().each(function(){
            $(this).width($(this).width());
        });
        return ui;
    };

    $(element).sortable({
        helper: fixHelper,
        axis: "y",
        cursor: "move",
        items: "tr.odd2",
        distance: "30"

    });
    $(element).disableSelection();
};

})(jQuery);
Run Code Online (Sandbox Code Playgroud)

父行具有类odd2,子行具有类child.

当应用.sortable()时,将2行锁定在一起的正确方法是什么?

我目前正在使用带有jquery-rails 1.0.19的rails 3.1.1

编辑:

这是相关的html

<table id="sortableTable">
  <tr class= 'headings'>
        <th><%= sortable "number" %></th>
        <th><%= sortable "customer_id" %></th>
        <th><%= sortable "priority" %></th>
        <th><%= sortable "quantity" %></th>
        <th><%= sortable "due_date" %></th>
        <th></th>
  </tr>

<% @jobs.each do |job| %>
  <tr class= "odd2">
    <td><%= job.number …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-ui ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1

5
推荐指数
1
解决办法
1939
查看次数