How to get key value from dropdownmenuitem on Zen Mojo Bootstrap?

I would like to know how to get the key value from a dropdownmenuitem placed on a navbar.

I have tried to get from onselect and onchange events of the template class, but it didn´t  work.

According to the snapshot attached I am trying to retrieve the values from 'action-1' and 'action-2'. 

I have attached a ZIP file with a snapshot which value I am trying to retrieve and example classes.

Thanks.

Comments

I don't think dropdown menu items support key property. Maybe you can use id property for your purposes instead?

Dropdownmenuitems did not attach event handlers when a key is present, which is a bug. This is fixed in the next release Zen Mojo 1.1.1. The new version is currently verified by QD, so you can expect a release within the next 2 weeks.

As temp  solution you can use href:"javascript:zenPage.StartEvent('yourkey','onclick','yourvalue');"

In your Zenpage add following ClientMethod to call events (sometimes useful for handling zen-events with bootstrap-plugins):

 

ClientMethod StartEvent(
key,
eventType,
value) [ Language = javascript ]
{
var newArea "events-" key.split(":")[0];
if (zenPage.currArea!==newArea) {
zenPage.currArea newArea;
zenPage.loadTemplateNS(zenPage.templateDispatchBaseNamespace+"/events",key.split(":")[0],newArea);
}
var st zenPage.getTemplate();
st[eventType](key,value,'mainView');
}

Jochen, this code will only work if the template dispatch mode is enabled. If you are running in standard mode, this is the code you need to make the sample work:

ClientMethod StartEvent(
key,
eventType,
value) [ Language = javascript ]
{
var st = zenPage.getTemplate();
st.[eventType](key,value,'mainView');
}

That should do it for both types:

ClientMethod StartEvent(
key,
eventType,
value) [ Language = javascript ]
{
if (zenPage.templateDispatchMode) {
var newArea "events-" key.split(":")[0];
if (zenPage.currArea!==newArea) {
zenPage.currArea newArea;
zenPage.loadTemplateNS(zenPage.templateDispatchBaseNamespace+"/events",key.split(":")[0],newArea);
}
}
var st zenPage.getTemplate();
st[eventType](key,value,'mainView');
}

This looks much better and should work.

Thanks for providing a workaround.

Stefan