get_linkElement().click() not working in Firefox

4 posts, 0 answers
  1. Bryan Kowalchuk
    Bryan Kowalchuk avatar
    19 posts
    Member since:
    Dec 2009

    Posted 05 May 2011 Link to this post

    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

  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 06 May 2011 Link to this post

    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.

  3. Bryan Kowalchuk
    Bryan Kowalchuk avatar
    19 posts
    Member since:
    Dec 2009

    Posted 06 May 2011 Link to this post

    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?

     
  4. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    651 posts

    Posted 12 May 2011 Link to this post

    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.

Back to Top