2013-01-21 69 views
0

我想添加一个复选框到使用JavaScript的TitlePane标题中,当选中它时将能够检查TitlePane内容中的所有复选框。我已成功通过下面的代码添加复选框:标题栏标题中的复选框

var cb = new dijit.form.CheckBox({name:"checkBox"}).placeAt(dijit.byId("someid").focusNode, "end"); 

然而,标志着为选中的复选框,激活TitlePane的打开/关闭动作。不确定如何将复选框的操作与TitlePane的操作分开。

基于耶利米的建议下,我用这个代码:

var selectGrp1DNew = new dijit.form.CheckBox({ 
    id : "grp1DButtonNew", 
    onClick: function(e){ 
     e.stopPropagation(); 

     //function to identify child checkboxes and turn then on/off 
     chkGrp(this); 
    } 

    //group1D is the TitlePane id 
}).placeAt(dijit.byId("group1D").focusNode, "end"); 

请帮帮忙, 萨米尔

回答

0

尝试在你的复选框的Click事件处理程序使用event.stopPropagation():http://dojotoolkit.org/reference-guide/1.8/quickstart/events.html

更新 看着你的更新代码和评论,我建议改为连接到CheckBox的onChange事件。

+0

Thanks!这对我很好,但增加了另一个问题。 TitlePane的开启/关闭操作不再有效。有什么想法可能会出错?除了TitlePane和其中的复选框之外,我还没有处理任何其他元素。 – samirg

+0

我已将新代码添加到原始文章 – samirg

+0

@samirg建议添加到我的答案中。 –

0

A TitlePane标题可以包含复选框。像这样:

var titlePane1 = new TitlePane({ 
     id: "titlePane1", 
     title: "input type='checkbox'/>", 
     content: "Collapse me!" , 
     open:false 
    }, "titlePane1");