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

radtoolbar AT RUNTIME and $find javascript

1 Answer 131 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Marco Silva
Top achievements
Rank 1
Marco Silva asked on 01 Apr 2010, 06:45 PM

I created a radtoolbar AT RUNTIME
But the javascript $find method does not find it.
That is the javascript code:

  function pesquisar(e) {
        if (e.keyCode == 13)
        {
            //radtoolbar is a runtime created RadToolBar
            //but can´t be found...
            var toolBar = $find("<%= radtoolbar.ClientID %>");
 
            //here the toolBar IS NULL and causes an error.
            var item = toolBar.findItemByText('Pesquisar');
 
            if (Telerik.Web.UI.RadToolBarButton.isInstanceOfType(item)) {
                item.click();
            }
         }
    }

I tried the getelementbyid method, but this does not return a Telerik.Web.UI.RadToolBarButton, but a [ObjectHtml DivElement].
So, the toolBar.findItemByText('Pesquisar') can´t be executed.
the javascript code:

  function pesquisar(e) {
        if (e.keyCode == 13)
        {
            // the getElementById does not return a RadToolBarButton
            var toolBar = document.getElementById("radtoolbar");
       
            var item = toolBar.findItemByText('Pesquisar');
            if (Telerik.Web.UI.RadToolBarButton.isInstanceOfType(item)) {
                item.click();
            }
         }
    }

But when I use a design time RadToolBar created, the $find method works fine

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 02 Apr 2010, 03:01 PM
Hi Marco Silva,

I already replied to your support thread:

It depends when exactly you call the pesquisar() method. Maybe you call it too early and the toolbar is still not created/initialized? You might find this blog post useful.

Best wishes,
Veskoni
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ToolBar
Asked by
Marco Silva
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or