2012-03-02 2 views
0

문제점이 있습니다. 나는 javascript 함수로 동적 HTML 코드를 만들고 dojo 대화 내용을 넣으려고합니다. 내 자바 스크립트 함수는 다음과 같습니다dojo 대화 상자 동적 내용 2

function doPushButton(doc, id, action, title, imgRef, text, width, style) { 
var tabIndex; 
if(arguments.length > 8) 
     tabIndex = arguments[8]; 
    var accessKey; 
    if(arguments.length > 9) 
     accessKey = arguments[9]; 
    jt_docWrite('<div class="' + style + '" style="cursor: pointer' + (width > 0 ? ';width:' + width + 'px' : '') + '"', doc); 
    if(id != null) 
     jt_docWrite(' id="' + id + '"', doc); 
    if(tabIndex != null) 
     jt_docWrite(' tabindex="' + tabIndex + '"', doc); 
    if(accessKey != null) 
     jt_docWrite(' accesskey="' + accessKey + '"', doc); 
    jt_docWrite(' title="' + title + '" onclick="' + action + '">', doc); 
    if(imgRef != null) 
     jt_docWriteln('<img class="label_icon right" src="' + imgRef + '"/>', doc); 
    if(text != null) 
     jt_docWriteln('<span class="label">' + text + '</span>', doc); 
    jt_docWriteln('</div>', doc); 
} 
jt_docWrite 및 jt_docWriteln는 JS 기능입니다

:

function jt_docWrite() { 
    if (arguments.length == 1) { 
     document.write(arguments[0]); 
    } 

    if (arguments.length == 2) { 
     arguments[1].write(arguments[0]); 
    } 
} 

그리고 도장 dialog.create이 doPushButton() 함수 임 전화 :

require(["dojo/ready", "dojo/parser"], function(ready, parser){ 
      ready(function(){ 
       var dialog = dijit.byId("myDlg"); 
       dojo.create('div', { 
        innerHTML: "Hello" 
        }, dialog.containerNode); 
        var div = dojo.create('div', {}, dialog.containerNode); 
        dojo.create('div', { 

        innerHTML: doPushButton(document, "yes", "doConfirm()", "", "../image/accept.gif", Res_yes_title, 0, "push_button") 

        }, div); 
        dialog.show(); 
      }); 

I을 <script> doPushButton(document, "yes", "doConfirm()", "", "../image/accept.gif", Res_yes_title, 0, "push_button") </script>과 같은 내 html 페이지에서 doPushButton() 함수를 사용하십시오. 제대로 작동하지만 이제는 dojo 대화 상자에 넣으 려합니다.이 함수는 "undefine"입니다. 누군가가 나에게 무엇이 잘못되었는지 도울 수 있습니까 ?? 고마워.

미로

답변

0

귀하의 doPushButton 방법은 값을 반환하지 않습니다. jt_docWriteln을 호출하면 포함 된 html을 문서에 씁니다. innerHTML 속성의 값은 Node 또는 String (HTML 일 수 있음)이어야하며 이므로 아무 것도 반환하지 않으므로 doPushButton이 반환됩니다.

관련 문제