documentation没有任何关于如何使用.submit([eventData],handler(eventObject))的示例
我有以下函数,我需要将url传递给row_save()函数.
function row_edit() { var url = $(this).attr("href"); var row = $(this).closest('tr') row.load( url + "/",null,function () { $("#save-form").submit(url,row_save); // ?? Not sure } ); return false; } function row_save() { var url = ???? var item = $(this).parent(); var data = { item_description: item.find("#id_item_description").val() }; $.post(url,data,function (result) { if (result != "failure") { item.before($("li",result).get(0)); item.remove(); $(".row_edit").click(row_edit); } else { alert("Failed to validate before saving."); } }); return false; }
谢谢
解决方法
eventData A map of data that will be passed to the event handler
function () { $("#save-form").submit({ "url": url },row_save); } function row_save(ev) { var url = ev.data.url; // ... }