如何在coffeescript中将两个jquery帖子合并为一个?

时间:2016-08-15 14:31:02

标签: javascript jquery ruby-on-rails coffeescript

我需要合并这两个对象:

{ swim_lane_id: $(this).closest('ul').data('lane-id') }

+

$(this).sortable('serialize')

到一个可以作为$ .post中的[DATA]发送的对象:

$.post($(this).data('update-url'), [DATA] );

$。merge仅提供swim_lane_id和id,它是update-url数据标记的一部分,但不提供可排序列表中的序列化数据。

我基本上需要能够在一个帖子中传递这些内容,因为update-url数据标记路由到我的Rails应用程序中的控制器操作,我需要知道哪个列表正在为发送给它的每个更新操作进行更新。

1 个答案:

答案 0 :(得分:1)

这看起来很简单:

$.post $(this).data('update-url'),
    swim_lane_id : $(this).closest('ul').data('lane-id')
    some_other_name : $(this).sortable('serialize')

您在一个对象中传递了两个属性。