Knockout.js OracleJet Splitbutton获取选择事件值

Knockout.js OracleJet Splitbutton获取选择事件值,knockout.js,split-button,oracle-jet,Knockout.js,Split Button,Oracle Jet,使用Oraclejet框架,我试图制作一个只有2个选项的splitbutton。如何区分它们,使它们各自发挥各自的功能?或者,如何粘贴选定的文本以用作参数 是这样的 <div id="dialogWrapper" style="position:relative; max-height:1%; max-width:1%;"> <button id="printPdf" style="margin-right:6px;"data-bind="

使用Oraclejet框架,我试图制作一个只有2个选项的splitbutton。如何区分它们,使它们各自发挥各自的功能?或者,如何粘贴选定的文本以用作参数

是这样的

<div id="dialogWrapper" style="position:relative; max-height:1%; max-width:1%;">
 <button id="printPdf" style="margin-right:6px;"data-bind="
                        ojComponent: {component: 'ojButton',            
                                      menu:'#choices'
                                      }"/>

里面的菜单:

 <ul id="choices" style="display:none"
      data-bind="ojComponent: {component: 'ojMenu', select: print//here both of them call to same function}">
 <li id="PDF">
         a href="#"><span class=""></span>PDF</a>
        </li>
        <li id="Excel">
        <a href="#"><span class=""></span>Excel</a>
     </li>     
  </ul> 
 </div> 
  • a href=“#”>PDF

这是通过使用选择处理程序函数的一些参数来完成的:

我重新创建了上面的示例并测试了以下代码:

<div id="dialogWrapper" style="position:relative; max-height:1%; max-width:1%;">
 <button id="printPdf" style="margin-right:6px;"data-bind="
                        ojComponent: {component: 'ojButton',            
                                      menu:'#printOptionsList',
                                      label: 'Print Option'
                                      }"/>
 <ul id="printOptionsList" style="display:none"
      data-bind="ojComponent: {component: 'ojMenu', select:printOptionHandler}">
 <li id="selPdf"><a href="#"><span class="oj-menu-item"></span>PDF</a></li>
 <li id="selExcel"><a href="#"><span class="oj-menu-item"></span>Excel</a>
     </li>     
  </ul> 
 </div> 

这是否也会在您这边呈现所需的输出?

这是通过使用选择处理程序函数的一些参数来完成的:

我重新创建了上面的示例并测试了以下代码:

<div id="dialogWrapper" style="position:relative; max-height:1%; max-width:1%;">
 <button id="printPdf" style="margin-right:6px;"data-bind="
                        ojComponent: {component: 'ojButton',            
                                      menu:'#printOptionsList',
                                      label: 'Print Option'
                                      }"/>
 <ul id="printOptionsList" style="display:none"
      data-bind="ojComponent: {component: 'ojMenu', select:printOptionHandler}">
 <li id="selPdf"><a href="#"><span class="oj-menu-item"></span>PDF</a></li>
 <li id="selExcel"><a href="#"><span class="oj-menu-item"></span>Excel</a>
     </li>     
  </ul> 
 </div> 

这是否也能提供您所需的输出?

它工作得很好。但是你能给我解释一下“ui.item.children”吗?这是什么意思这是我在jet CookBook中看到的访问菜单当前状态的示例:jQuery ui.item.children([selector])在所选项(在本例中,我们选择了一个
  • 元素)中搜索目标元素——在本例中,是一个链接元素(),其中存储了文本值。因此ui.item.children(“a”).text()访问器。它工作得非常好。但是你能给我解释一下“ui.item.children”吗?这是什么意思这是我在jet CookBook中看到的访问菜单当前状态的示例:jQuery ui.item.children([selector])在所选项(在本例中,我们选择了一个
  • 元素)中搜索目标元素——在本例中,是一个链接元素(),其中存储了文本值。因此,ui.item.children(“a”).text()访问器。