2
我有這樣的紅寶石代碼:回調與鏈接數據的遠程=「true」和數據方法=「PUT」
link_to t("general.actions.#{ action }"), [action, @app, item], {
:method => :put,
:remote => true,
:onclick => '$(this).closest("tr").find("td").fadeOut()'
}, :class => 'status'
產生這個網站:
<a href="/apps/guess-the-model/contents/52118140d644363dc4000005/approve"
data-method="put"
data-remote="true"
onclick="$(this).closest("tr").find("td").fadeOut()"
rel="nofollow">
approve
</a>
問題是的,我不應該使用onclick。我應該只在AJAX成功時調用這個js代碼,所以我應該通過回調並檢查XMLHttpRequest狀態。我如何使用:remote => true
和:method= :put
來做到這一點?
我想,你應該在方法的js模板中寫入這個js,它被遠程鏈接調用。 –