我正在使用Knockback.js。我是这整个javascript和html的新手。我试图在函数 addFolder 中弹出隐藏字段,但它总是显示为null。 这是以下javascript代码(viewmodel)。
GroupsView = LS.ViewModel.extend({
initialize : function(options) {
if(typeof options != 'undefined'){
this.projectskey = options.projectskey;
this.folderkey = options.folderkey;
}
this.options = options;
this._this = this;
this.c = new GroupsCollection(null, options);
this.c.fetch({
add : true
});
this.groups = kb.collectionObservable(this.c);
},
fetch : function() {
$('#loadingAnim').show();
this.groups.collection().fetch({
update : true,
add : true
});
},
addFolder: function(vm, event){
event.preventDefault();
$("#plgGroupsGetContents").val(vm.projectskey);
$("#plgGroupsGetContents1").val(vm.folderkey);
vm.c.addFolder();
$('#dialogAddFolders').modal('hide');
}
});
这是以下的html代码
<form action="/groups/createfolder" id="addFoldersForm" data-bind="event: {submit: $root.addFolder.bind() }">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel" data-bind="text: LANG.getText('plgGroupAddFolder')"></h4>
</div>
<div class="modal-body">
<input type="hidden" name="projectskey" id="plgGroupsGetContents" value="">
<input type="hidden" name="rootfolder" id="plgGroupsGetContents1" value="">
<span data-bind="text: LANG.getText('plgGroupFolderName')"/><input type="text" data-bind="attr: {placeholder: LANG.getText('plgNameDefaultText')}" required title="Folder name" name="foldername" data-icon="U"><br>
</div>
<div class="modal-footer">
<button data-bind="text: LANG.getText('plgGroupAbort')" type="button" class="btn btn-default" data-dismiss="modal"></button>
<button data-bind="text: LANG.getText('plgGroupAddFolderOKBtn')" class="btn btn-primary"></button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
你能告诉我一些想法吗? 提前致谢