function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

dataTable id not recognized by jQuery



If I have a dataTable with id = tableId and use jQuery to access it using $("#tableId") it doesn't work. But when I create the same table using regular HTML tags it works.


Anybody know's what's going on?




Is your table embedded within other Visualforce elements? If so, you need to chain together the ids for those elements. For example, if you had the following:


   DataTable1 (Enclosed in PageBlock1)


You'd reference DataTable1 as follows:




(Use the single-quoted text.) Let me know if that works.


-- Matt

You're right. Thanks. But that's not working with jQuery. This is what I use:



Message Edited by asadim on 01-15-2010 03:00 PM

The semi colons visualforce generates makes jQuery not work. It is discussed here:


but even the solution provided doesn't always work. What I have done is give elements styleClasses and they use this in the the jQuery selectors. Peformance may not be as great but you don't have to deal with the potential of ids changing.

Message Edited by TehNrd on 01-18-2010 04:17 PM

Just for reference:





// Because Salesforce builds up ID's for it's objects with goofy names concatenated
// together with colons, it becomes difficult to use Name selectors because the ':'
// has meaning to the selector syntax.  So, they must be escaped.
// A helper function to prefix colons in the Id's with backslashes so that they 
// can be used in jQuery selectors
// Usage: $(colonblow('{!$Component.theNewProject}')).dialog('open');
// Note: colonblow = SNL Homage
function colonblow(id) { 
	return '#' + id.replace(/(:)/g,'\\\\$1');