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

'Normal' Javascript Objects vs. jQuery Objects

3 Answers 63 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 31 Dec 2010, 10:30 PM
I'm confused about something that is directly related to my work with Telerik controls.  Supposed you had a RadSlidingZone implemented on a web page.  Now look at these two ways to identify this object in client-side code:
  1. $find("<%= radSlidingZone.ClientID %>");
  2. $('table[id$=radSlidingZone]')[0];

The first uses, what I believe is called, an embedded ASP.net object.  The second uses jQuery.

At first I thought that the resulting objects would be identical.  But a simple test - namely, calling .get_id() revealed that they're not.

I was told elsewhere that the 2nd object is referred to as a "Normal Javascript Object".  If so, then what's the first one?  Put another way, if it's not a "normal" Javascript object then what is it?

Hoping someone can explain, which will hopefully help others too.

Thank you,

Robert Werner
Vancouver, BC

3 Answers, 1 is accepted

Sort by
0
Kamen Bundev
Telerik team
answered on 01 Jan 2011, 07:48 AM
Hello,

The first piece of code will retrieve the ASP.NET client object of RadSlidingZone.

The second piece of code gives you the first table DOM element on the page whose ID ends with radSlidingZone. The DOM element is a javascript object which represents an HTML element in your page and it has nothing to do with jQuery (it is just used for finding it). This is the same element you can retrieve with $find("<%= radSlidingZone.ClientID %>").get_element().

Regards,
Kamen Bundev
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
Robert
Top achievements
Rank 1
answered on 02 Jan 2011, 02:48 AM
Kamen,

Let me rephrase my question because you clearly didn't understand what I was asking.  Let's look at the two pieces of code again:
  1. var a = $find("<%= radSlidingZone.ClientID %>");
  2. var b = $('table[id$=radSlidingZone]')[0];
The first retrieves a client-side object with which I can use various methods provided by Telerik such as get_id().  Thus I can successfully execute this code:    var id = a.get_id();

The second, however, appears to retrieve something similar to the first but not exactly the same.  Thus this fails:  var id = b.get_id();

What I'd ideally like to know is how, using jQuery, I can retrieve exactly the same object as is populated in 'a'.  Surely there must be a way, no?

Robert
0
Kamen Bundev
Telerik team
answered on 06 Jan 2011, 09:54 AM
Hello,

Yes, there is a way - get the ID and use $find again, like this:
var b = $find($('table[id$=radSlidingZone]')[0].id);

Greetings,
Kamen Bundev
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
General Discussions
Asked by
Robert
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Robert
Top achievements
Rank 1
Share this question
or