Jquery sortable('serialize')

前端 未结 6 1552
遥遥无期
遥遥无期 2021-02-01 08:57

Is it possible to get the serialized list of items from a UL in jquery by calling the serialize method directly instead of using a callback? The code snippet:

va         


        
6条回答
  •  遇见更好的自我
    2021-02-01 09:32

    I was able to get this function working using the split. If you have multiple underscores in your class you may need to adjust the index

    function serializeList(container)
    {
      var str = ''
      var n = 0
      var els = container.find('tr')
      for (var i = 0; i < els.length; ++i) {
        var el = els[i]
    
        var p = el.id.lastIndexOf('_')
        **var getIdNumber = el.id.split("_");**
    
        if (p != -1) {
          if (str != '') str = str + '&'
          str = str + el.id.substring(0, p) + '[]=' + **getIdNumber[1]**
          ++n
        }
      }
      return str
    }
    

提交回复
热议问题