PDA

View Full Version : How to change href property of button's component ?



Doc Zhivago
23 Oct 2012, 2:08 AM
Latest ExtJS (4.1.2)
How to change href property of button's component ? I was no found setHref method in the API doc's.

loiane
23 Oct 2012, 3:11 AM
You can change it directly like this:


buttonInstance.href = 'new value';

Allan Stark
23 Oct 2012, 3:25 AM
You can change it directly like this:

buttonInstance.href = 'new value';
This will not change realy href property in <a...> tag in DOM, only href in ExtJS object...
I have the same problem: http://www.sencha.com/forum/showthread.php?245393-Button-drop-down-menu-and-href&p=897072#post897072

T (http://www.sencha.com/forum/showthread.php?245393-Button-drop-down-menu-and-href&p=897072#post897072)he solution is to set id property in the button object and update DOM like this:


Ext.getDom('e_tif-itemEl').href = 'http://..........'

Dirty way, but the other did not find...

James Goddard
23 Oct 2012, 4:49 AM
What they said.

Doc Zhivago
23 Oct 2012, 5:01 AM
I do not need a DOM.
I need to dinamically change href property of ExtJS button: add some GET parameters, that will be sent to server.
The question is: how ?
If I change like this:


Ext.getCmp('mybutton').href = 'http://extjstest/test.php?par1=1&par2=2';

it will change this property in DOM only once, the next use will not change and button work incorrectly (sends old parameter's values).

Doc Zhivago
23 Oct 2012, 10:40 PM
Hey guys, did anyone come across? Property of a button to change depending on the specific actions - frequent situation.
In JQuery classes and DOM are fully synchronized...

ettavolt
24 Oct 2012, 3:37 AM
Try changing href property of button component instance and then invoke http://docs.sencha.com/ext-js/4-1/#!/api/Ext.button.Button-method-setParams

bizsysdev3
14 Aug 2013, 7:25 AM
this worked for me (using v4.2.1):

button.href = '#new_link';
button.el.dom.href = button.getHref();

evant
14 Aug 2013, 3:16 PM
4.2.x has a setHref method.

bizsysdev3
15 Aug 2013, 6:58 AM
ah! Thanks, that works. The contents of the function actually are *exactly the same* what I just posted above, too.

Note that you MUST set the 'href' property (to anything) when defining the component in order for the 'setHref()' method to work.