开发者

How to pass parent object's id along with my serialised sortable items?

开发者 https://www.devze.com 2023-01-26 06:46 出处:网络
I\'ve got an Ajax call from the stop event of my jQuery UI sortable that currently looks like this: ...

I've got an Ajax call from the stop event of my jQuery UI sortable that currently looks like this:

...
stop:function(event, ui) {
    $.ajax({
        type: "POST",
        url: "<?php echo site_url('messages/reorder'); ?>",
        data: $("#messagelist").sortable("serialize")
    });
...

Now, that's fine, and it's working (messages/re开发者_Python百科order is a server-side Ajax function that updates the database based on the serialised IDs.)

However, I have multiple lists I could be editing from this page, and I need to pass along the ID of the "parent" object of the list, too.

Is there a standard way of doing this? I know the ID server-side when generating the page. Is there a best-practice way of adding the ID to the "data" that's passed along in my Ajax call?

Sorry if I'm missing something obvious; I'm fairly new to jQuery and Javascript and entirely new to "sortable"...


I ended up doing this by the simple expedient of:

data: "parent_id=" + p_id + "&" + $("#messagelist tbody").sortable("serialize")
0

精彩评论

暂无评论...
验证码 换一张
取 消