编辑*****
嗨,我的代码第一次工作正常,但是第二次,我的对象函数返回undefined。
PS:我编辑了这篇文章,以放置更长的脚本,以更好地理解。PS2:预先谢谢您:)
_MANAGE = new Object()
//----------------------------- BG ------------------------------//
var saveBg = {
name : "bg",
url : "AN URL",
data : {
ID :function($this){ return $this.parents("tr").data("id") },
name :function($this){ return $this.parents("tr").find(".name").val() }
}
}
//----------------------------------------------------------------------//
//------------------------- SAVE FUNCTION ------------------------------//
var saveButton = [saveBg];
$(".buttonSave").on("click", function(){
console.log(saveBg);
var buttonName = $(this).data("name");
_MANAGE.saveButton(saveButton, buttonName, $(this));
})
//----------------------------------------------------------------------//
//------------------------- SAVE BUTTON ------------------------------//
_MANAGE.saveButton = function(saveButton, buttonName, $this_button){
for(var i = 0; i < saveButton.length; i++){
if(buttonName == saveButton[i]["name"]){
for(var param in …
Run Code Online (Sandbox Code Playgroud)