Reputation: 353
I made the following function with extjs that change the clicked Href and the last part:
document.getElementById("#device").href = url;
is not working.
I tried with extjs function get to select and change my href ... but same result.
Any solution or other way to do this ?
Ext.select('#tab-home-view ul li a').on('click', function (ev) {
var url = window.location.href;
url = url.replace("http://localhost:8080", "");
Ext.select('#tab-home-view ul li').removeCls('active');
Ext.get(ev.currentTarget).up('li').addCls('active');
var current = Ext.get(ev.currentTarget).getAttribute('href');
url = url + current;
document.getElementById("#device").href = url;
});
my tabs :
<div class="tabs" id="tab-home-view">
<ul class="tab-links">
<li id="General" class="active"><a href="&activeTabHomeAgregateSite=0">General</a></li>
<li id="device"><a href="&activeTabHomeAgregateSite=1">Device</a></li>
<li id="link"><a href="&activeTabHomeAgregateSite=2">Link</a></li>
<li id="Service"><a href="&activeTabHomeAgregateSite=3">Service</a></li>
</ul>
</div>
Upvotes: 0
Views: 1064
Reputation: 4355
Ext.get()
obtains an ext element.
You need to use the property dom
on the element to modify the href
. However, div
is also the parent of the a
element; so you need to go down
to the <a>
.
You could modify the href with the following:
Ext.get('device').down('a').dom.href = '/newhref';
Upvotes: 1
Reputation: 653
Get rid of the #:
document.getElementById("device").href = url;
That's regular JavaScript syntax. I'm not really familiar with extjs, so I don't know what else I would try. Maybe this could help: ExtJS - How to get DOM ID of a component?
Upvotes: 0