knockout.js - OracleJet Splitbutton get select event value -


using oraclejet framework, trying make splitbutton has 2 options. how can differentiate them each go own function? or how can paste text of selected function parameter?

it this

<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'                                       }"/> 

the menu inside:

 <ul id="choices" style="display:none"       data-bind="ojcomponent: {component: 'ojmenu', select: print//here both of them call same function}">  <li id="pdf">          href="#"><span class=""></span>pdf</a>         </li>         <li id="excel">         <a href="#"><span class=""></span>excel</a>      </li>        </ul>   </div>  

this done using parameters of selection handler function:

i've recreated example above , tested code:

<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>  

as script part, i've added printoptionhandler main knockout object:

self.printoptionhandler = function(event,ui){             var sel = ui.item.children("a").text();             //alert('option selected: ' + sel);             if (sel == "excel") {                 alert("calling excel function");             } else if (sel == "pdf"){                 alert ("calling pdf function");             }         }; 

does render desired output on side well?


Comments