Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't trigger click event on a link

My problem is that I got 2 aspx controls generated like this :

<a id="sortByDate" href="javascript:__doPostBack('sortByDate','')">Date</a>
<a id="sortByLastName" href="javascript:__doPostBack('sortByLastName','')">Last name</a>

so those links allow you to sort the results. I'm trying to put this in a combobox instead of using links.

So I made it like this

<select id="sortBySelect" onchange="javascript:sortBy(this);">
       <option value="sortByLastName">Last name</option>
       <option value="sortByDate">Date</option>
</select>

with this javascript function

function sortBy(sel) {
    var id = sel.value;
    $("#" + id).trigger("click");
}

So when you change the selected element in the combobox I want to trigger the click event on the link to call the dopostback to sort.

It does nothing so far. I tried "click", "onclick", "onClick" and nothing works. Unfortunately, this is for IE quirks mode.

I know, this is really not elegant, but I'm really short in time and I need something quick and dirty. I will make an aspx control eventually to handle this nicely.

Any ideas how I could make this work in ie quirks mode?

Thank you

like image 599
Marc Avatar asked Feb 16 '23 02:02

Marc


1 Answers

Try changing the location of the page:

document.location = $("#" + id).attr('href');
like image 130
Jonathan Naguin Avatar answered Feb 27 '23 17:02

Jonathan Naguin