This is a migrated thread and some comments may be shown as answers.

get_linkElement().click() not working in Firefox

3 Answers 63 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bryan Kowalchuk
Top achievements
Rank 1
Bryan Kowalchuk asked on 05 May 2011, 08:40 PM
I am simulating the click of a treview node in Javascript using

get_linkElement().click()

This works perfect in IE8, but Firefox 4.0 and Chrome cannot find the click() function and raises an error.

Any ideas on how I can work around this?

Thanks

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 06 May 2011, 04:48 PM
Hi Bryan,

Well, this simply is not supported by Firefox.
Please, explain what exactly do you try to achieve and perhaps we will be able to help you find an alternative.


Regards,
Nikolay Tsenkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Bryan Kowalchuk
Top achievements
Rank 1
answered on 06 May 2011, 04:59 PM
When user opens the form, treeview is displayed in a frame on the left side, content is in a frame on the right side.

The behaviour I would like is to have the first unselected content be displayed. I determine the first unselected treeview node, them simulate the user clicking the node using get_linkElement().click().

I suppose I could get the link element URL, and set the content frame href?

 
0
Ivan Zhekov
Telerik team
answered on 12 May 2011, 08:15 AM
Hello Bryan Kowalchuk,

Is it a static link e.g. <a href="http://telerik.com">Click Here</a>, or is it a PostBack type of link e.g. <a href="javascript:SCRIPT">Click</a>?

Both require different approaches, but they can be solved using the following snippet:

function simulateClick(link) {
 
    if (!link) return;
 
    // Trigger onclick evenets from jQuery
    // $(link).click();
     
    if (link.href && link.href.indexOf("javascript:") == -1) {
     
        // Case 0: simple link
        // console.log("SimulateClick: Case 0")
        window.location = link.href;
         
    } else if (link.href && link.href.indexOf("javascript:") == 0) {
 
        var script = link.href.substring(11);
 
        // Case 1: <a href="javascript:...">...</a>
        // console.log("simulateClick: Case 1");
        if (script.indexOf("WebForm") == 0) {
            eval(unescape(script));
        } else {
            eval(script);
        }
 
    } else if (link.onclick) {
 
        // Case 2: <a onclick="...">...</a>
        // console.log("simulateClick: Case 2");
        eval(link.onclick);
 
    }
}

Let us know if this achieves the behaviour you want.

Regards,
Ivan Zhekov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
TreeView
Asked by
Bryan Kowalchuk
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Bryan Kowalchuk
Top achievements
Rank 1
Ivan Zhekov
Telerik team
Share this question
or