View Full Version : Button, drop-down menu and href

Allan Stark
9 Oct 2012, 12:47 AM
ExtJS ext-4.1.1a-gpl.zip
MVC application, a drop-down menu in button.
The href config in menu is missing in documentation, but it true exist (there is a possibility to read/write it).
The bug is of trying to change this (href) property. It change only once (first assignment property).


id: 'toolbar_panel',
xtype: 'toolbar',
dock: 'top',
height: 35,
items: [{
xtype: 'button',
text: 'Download:',
itemId: 'export_button',
arrowAlign: 'right',
icon: 'images/gears.png',
menu : [{

text: 'Export to TIFF /TIF',

itemId: 'export_tiff',
id: 'e_tiff',
href: 'download_cert.php',
hrefTarget: '_window',
icon: 'images/tif_format.png'


text: 'Export to JPEG/JPG',
itemId: 'export_jpeg',
id: 'e_jpeg',
href: 'download_cert.php',
hrefTarget: '_window',
icon: 'images/jpg_format.png'


Change the href (first try):

console.log(Ext.getCmp('e_jpeg').href); // see 'undefined'
Ext.getCmp('e_jpeg').href = 'download_cert.php?test=1';
console.log(Ext.getCmp('e_jpeg').href); // see 'download_cert.php?test=1'

When menu is drop-down, see 'download_cert.php?test=1' in browser's url hint when mouse is over 'Export to JPEG/JPG' menu button. When clicking - see open 'download_cert.php?test=1' in new browser's window. All works fine.

Change href again (f.e. change href by clicking in other button):

Ext.getCmp('e_jpeg').href = 'download_cert.php?test=2';
console.log(Ext.getCmp('e_jpeg').href); // see 'download_cert.php?test=2'

BUT ! Now when mouse is over 'Export to JPEG/JPG' menu button for some reason we see old href value: download_cert.php?test=1 in browser's url hint 8-|
And when we click this button 'Export to JPEG/JPG', we see old url - 'download_cert.php?test=1' in new browser's window...

Is this bug or my mistake ?

9 Oct 2012, 12:53 AM
It's your bug, you need to update the DOM, you can't just update a property on an unrelated object:

menuItem.itemEl.dom.href = 'Foo';

That being said, it would be nice to have a setHref method similar to button.

Allan Stark
9 Oct 2012, 1:40 AM
Am... I'm so sorry, but in Sencha's online documentation (ExtJS 4.1.2) the button component has no setHref method...

?an once again an example of solving a case of my code?

And of course, this method would be very useful in the case of drop-down menu buttons...