我有这个代码:
collection = (function() {
function collection(removeLinkTitle){
this.removeLinkTitle = removeLinkTitle || 'delete';
}
collection.prototype = {
removeLinkTitle: this.removeLinkTitle,
init:function(){
...some code...
this.deleteCollectionForm();
},
deleteCollectionForm:function(){
var removeFormA = $('<a href="#">'+this.removeLinkTitle+'</a>');
linkLi.append( removeFormA );
removeFormA.on('click', function(e) {
e.preventDefault();
linkLi.remove();
var index = collectionHolder.data( 'index' );
collectionHolder.data( 'index', index - 1 );
});
}
};
return collection;
})();
问题是 var removeForm 仅在第一次加载时才返回其值,随后又返回 undefined。
我不想将变量作为参数传递,有没有其他方法可以做到这一点?
谢谢 !!