2014-11-18 2 views
0

다른 맞춤 위젯 (대화 상자)을 여는 맞춤 위젯 (버튼)이 있습니다. 첫 번째 위젯 (버튼이 잘 표시되어 있지만, 나는 두 번째 위젯을 열 때 나는 주제 오류를 받고 있어요.잡히지 않은 유형 오류 번호가 맞춤 위젯의 기능이 아닙니다.

버튼 위젯 (myButton.js)

define([ 
    "custom/myDialog.js", 
    "dijit/_WidgetBase", 
    "dijit/_TemplatedMixin", 
    "dijit/_WidgetsInTemplateMixin", 
    "dojo/_base/declare", 
    "dojo/text!./myButton.html", 
    "dijit/form/Button" 
], function(myDiag, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, declare, myTemplate) { 
    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], { 
    templateString: myTemplate, 

    OpenDialog: function(){ 
     var d = new myDiag({});//uncaught type error: number is not a function 
     d.myDialog.startup(); 
     d.myDialog.show(); 
    } 
    }); 
}); 

버튼 템플릿 (myButton.html)

<div> 
<button data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick:OpenDialog">click for dialog</button> 

</div> 

대화 위젯 (myDialog.js)

define([ 
    "dijit/_WidgetBase", 
    "dijit/_TemplatedMixin", 
    "dijit/_WidgetsInTemplateMixin", 
    "dojo/_base/declare", 
    "dojo/text!./myDialog.html", 
    "dijit/form/Select", 
    "dijit/Dialog" 
], function(_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, declare, myTemplate) { 
    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], { 
    templateString: myTemplate, 
    }); 
}); 

대화 상자 템플릿 (myDial og.html)

다음
<div> 
<div data-dojo-type="dijit/Dialog" title="Mark Ticket" data-dojo-attach-point="myDialog"> 
<select id="selectReach" style="width: 150px; height:20px;" data-dojo-type="dijit/form/Select"> 
       <option selected="selected">IV</option> 
       <option>IVA</option> 
       <option>IVB</option> 
       <option>IVD</option> 
       <option>IVE</option> 
       <option>V</option> 
       </select> 
       </div> 
</div> 

plunker

감사

답변

0

myButton.js에있는 당신의 require myDialog'custom/myDialog'하지 'custom/myDialog.js'해야한다 :

define([ 
    "custom/myDialog", 
    "dijit/_WidgetBase", 
    ... 

거기에의 .js로 , Google CDN에서 myDialog.html을로드하려고 시도합니다. Google CDN은 분명히 찾을 수 없으므로 Dialog.js가 실패합니다.

"상대 모듈 식별자"(올바른 모듈을로드하고 이식성을 높이기 위해)를 사용하여 동일한 패키지의 다른 모듈을 요구하는 것이 일반적이므로 코드에 적용되는 경우 './myDialog'으로 변경해야합니다. 상태. this tutorial의 "휴대용 모듈 작성"절을 참조하십시오.

기타 참고 사항 : 패키지 선언에 사용중인 window.location 메서드는 사용자가 이 아닌 directory/을보고있는 경우에만 작동합니다.

id="SelectReach"을 myDialog.html에서 제거하고 싶습니다. 대화 상자를 두 번 이상 열어 볼 때 "이 ID는 이미 등록되었습니다"라는 오류가 표시됩니다. 템플릿에서 ID를 사용하지 마십시오. 선택 입력을 참조해야하는 경우 클래스 및 query을 사용할 수 있습니다.

는 그리고 당신은 myDialog.js에 콤마, 라인이 도움이 (11)

희망이있다.

+0

해결책 및 기타 제안을 보내 주셔서 감사합니다. – pvitt

관련 문제