2012-02-05 3 views
2

저는이 링크에서 IBM의 자습서를 가지고 놀았습니다.Dojo : 새 그룹을 추가 한 후 드롭 다운 목록을 업데이트 할 수 없습니다.

http://www.ibm.com/developerworks/web/tutorials/wa-dojotoolkit/section6.html

지금까지 아주 잘 했어,하지만 난 새 그룹 항목을 채울 드롭 다운 목록을 얻을 수 없습니다. 심지어 원래 코드가 작동하지 않습니다.

//Refresh the data store for the groups dropdown (in case groups added, edited or deleted) 
function refreshGroupDropDown() { 
    var theStore = dijit.byId("edit_contact_group").store; 
    theStore.close(); 
    theStore.url = "data/groups.php"; 
    theStore.fetch(); 
} 

고마워요!

업데이트 : 여전히 문제가 있습니다. 나는 이것을 아래에서 시도했지만 여전히 아무것도하지 않았다. refreshGroupDropDown() 함수는 사용자가 연락처 편집 창이나 새 연락처 창을 열 때 호출됩니다.

//Refresh the data store for the groups dropdown (in case groups added, edited or deleted) 
function refreshGroupDropDown() { 
    var new_store = new ItemFileReadStore({url: 'data/groups.php' , clearOnClose: true}); 
    var theStore = dijit.byId("edit_contact_group"); 
    theStore.store = new_store; 
    theStore.close(); 
    theStore.fetch(); 

} 

    //Clears the "Edit Contact" form, sets it up for adding a new contact 
function newContact() { 
    var contact = contactsGrid.selection.getSelected()[0]; 
    refreshGroupDropDown(); 
    dojo.byId("edit_contact_real_id").value = ""; 
    dojo.byId("edit_contact_id").value = "[NEW]"; 
    dijit.byId("edit_contact_group").reset(); 
    dijit.byId("edit_contact_first_name").reset(); 
    dijit.byId("edit_contact_last_name").reset(); 
    dijit.byId("edit_contact_email_address").reset(); 
    dijit.byId("edit_contact_home_phone").reset(); 
    dijit.byId("edit_contact_work_phone").reset(); 


    dijit.byId("editContactDialog").set("title", "New Contact"); 
    dijit.byId("editContactDialog").show(); 
} 

    //Process the adding of a new group to the database 
function doNewGroup(e) { 
    e.preventDefault(); 
    e.stopPropagation(); 
    dojo.byId("new_group_ajax").value = "1"; 
    if(this.isValid()) { 
     dojo.xhrPost({ 
      form: this.domNode, 
      handleAs: "json", 
      load: function(data) { 
       if(data.success) { 
        okDialog.set("title","Group created successfully"); 
        okDialogMsg.innerHTML = "The group <strong>"+data.name+"</strong> was created successfully."; 

        groupsStore.newItem({"id":data.id.toString(),"name":data.name}, {"parent": groupsModel.root, "attribute":"groups"}); 
        groupsStore.save(); 

        newGroupDialog.hide(); 
        okDialog.show(); 
       } 
       else { 
        okDialog.set("title","Error creating group"); 
        okDialogMsg.innerHTML = data.error; 
        okDialog.show(); 
       } 
      }, 
      error: function(error) { 
       okDialog.set("title","Error creating group"); 
       okDialogMsg.innerHTML = error; 
       okDialog.show(); 
      } 
     }); 
    } 
} 

이 정보가 도움이되기를 바랍니다. 나는 초보자이므로 어떤 도움을 주시면 감사하겠습니다.

답변

2

나는 그것을 알아 냈다! 문제는 index.html에있었습니다. 그룹 드롭 다운 목록의 입력 태그는 다음과 같습니다.

<input dojoType="dijit.form.FilteringSelect" name="move_contact_new" store="groupsStore" searchAttr="name" query="{type:'node'}" id="move_contact_new" required="true" style="margin-bottom: 6px" /> 

쿼리 속성이 올바르게 설정되지 않았습니다. query = "{type : 'node'}"를 삭제하면 그룹이 추가, 수정 또는 삭제 된 후에 그룹이 다시 채워집니다.

초급 질문을위한 초급 응답입니다.

희망 사항은 초보자를 도울 수 있기를 바랍니다.

0

내가 게시 한 내용에 따르면 데이터 입력란을 acutally 생성하지 않기 때문에 표시되는 유일한 문제는 var theStore = dijit.byId("edit_contact_group").store;입니다. `var edit_contact_group = new dojo.data.ItemFileReadStore(); 또는 이와 동등한 것을 포함시켜야합니다. 그런데 dojo.connect()를 사용하여 refreshGroupDropDown() 함수를 적절한 이벤트 ('onclick'또는 기타)에 연결 했습니까? dojo.ready를 사용하여 refreshGroupDropDown() 함수를로드 했습니까? 즉. dojo.ready(function(){refreshGroupDropDown();}); 그것들은 항상 마음에 오는 첫 번째 것들입니다 ...

관련 문제