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

Javascript Intellisense

3 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christopher Blickley
Top achievements
Rank 2
Christopher Blickley asked on 15 Mar 2010, 06:45 PM
What is the best way to get Javascript Intelliense working on the controls within an client-side event when an item is passed into the event instead of the entire RadControl?  For example, in the RadMenu's OnClientItemClicking event, the second parameter passed in has a "get_item" functioin that grabs the RadMenuItem that was clicked. Is there a way to get Intellisense working on that item?  An example would in the following snippet from the docs, where I would love to get Intellisense on the "item" variable.

Thanks,
Chris

<script type="text/javascript">  
function onClicking(sender, eventArgs)  
{  
  var item = eventArgs.get_item();  
  var navigateUrl = item.get_navigateUrl();  
  if (navigateUrl && navigateUrl != "#")  
  {  
    var proceed = confirm("Navigate to "+ navigateUrl + " ?");  
    if (!proceed)  
    {  
      eventArgs.set_cancel(true);  
    }  
    else 
    {  
      eventArgs.set_cancel(false);  
    }  
  }  
}  
</script>  
 

3 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 16 Mar 2010, 11:26 AM
Hello Christopher Blickley,

At this moment it is a limitation because there is no easy way to say to handler what item it contains.

Sorry for the inconvenience.
 
Best wishes,
Veronica Milcheva
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.
0
Christopher Blickley
Top achievements
Rank 2
answered on 16 Mar 2010, 12:11 PM
Thanks Veronica,

Maybe a future enhancement could be to provide functions for the items like are currently being provided for the main control, like "toMenuItem()".  I worked around it be calling "toMenu" on the first parameter, then called "findItemByValue" on the RadMenu object, passing in eventArgs.get_item();  This seems to work, but requires those extra steps.  I suspect that many people would benefit from Intellisense on the "item" objects passed in to the client-side handlers since, at least in my case, this is the most frequent place I work with the RadControls on the client.

Thanks,
Chris
0
Dimitar Milushev
Telerik team
answered on 19 Mar 2010, 04:12 PM
Hi Christopher Blickley,

Thank you for the suggestion. We'll make sure to make this improvement in future versions as it will be useful indeed.

Meanwhile, you can create your own 'toMenuItem' method:

function toMenuItem(object) {
    /// <summary>Casts an object to a RadMenuItem instance</summary>
    /// <returns type="Telerik.Web.UI.RadMenuItem">A RadMenuItem instance</returns>
    return object;
};

It simply returns the passed object which is enough to give Visual Studio a 'hint' about the returned type.

Kind regards,
Dimitar Milushev
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
General Discussions
Asked by
Christopher Blickley
Top achievements
Rank 2
Answers by
Veronica
Telerik team
Christopher Blickley
Top achievements
Rank 2
Dimitar Milushev
Telerik team
Share this question
or