3
我讀this issue在jquery-rails,因爲我想在發送數據之前添加一些數據。Rails 3.1,jQuery:在發送數據前將數據附加到表單
說明看起來很簡單:掛在before:send
上,並做你想要的形式。我就是這麼做的:
form.live "ajax:before",() ->
form.data('params', sortableList.nestedSortable('serialize'))
console.log "data we're sending along: " + form.data('params') # here I see the data I want to append to the form
的POST
但不包含任何數據我加入到data-params
的:
Started POST "/admin/site/nav_items/render_event_response?source=menu_item_tree&type=submit" for 127.0.0.1 at 2011-09-29 20:48:11 +0800
Processing by Admin::Site::NavItemsController#render_event_response as JS
Parameters: {"authenticity_token"=>"sV8eEMpIVicbmT0nAfDdChgpRMyI5yR/N6m5VLk3+/Q=", "source"=>"menu_item_tree", "type"=>"submit"}
User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
...snip...
我才明白that issue錯了嗎? 如何在發送數據之前將數據附加到表單上?
謝謝!
是越來越搞糊塗了,直到我意識到CoffeeScript的參與... – thomasfedb