CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Kyle Baley - The Coding Hillbilly

"We are stuck with technology when what we really want is just stuff that works" -- Douglas Adams

jQuery and the ConventionController

Well here's a fine how-do-ya-do. I'm using the ConventionController from MVCContrib which means I have controls with IDs like dto.JobName and dto.OrderedDate.

Problem is, I can't get at these things by ID in jQuery anymore. "#dto.JobName" in jQuery means (if my memory of CSS serves) select all elements with an ID of dto and a CSS class of JobName. Even if that's wrong, it doesn't matter much. The end result is $( "#dto.JobName" ) returns a useless object.

Current workaround is to select by name. Like so: $( "input[name='dto.JobName']" ) or $( "select[name='dto.JobTypes'] ).

Kyle the Selector



Comments

Ken Egozi said:

I *think* that a dot in id is not allowed. that's why MonoRail helpers turn dots to underscores, and WebForms transforms dots to dollars. Well MS stuff turns everything into dollars though ..

# April 13, 2008 2:09 AM

Joshua Flanagan said:

You're willing to dive into the guts of an open source linq provider, but got scared away from trying to figure out how to fix the mvccontrib code so that an underscore is used instead of a period? Come on, Hillbilly Up!

# April 13, 2008 4:34 PM

Kyle Baley said:

@Joshua

The Hillbilly is an enigma wrapped in a mystery covered with a smooth chocolatey coating.

He's also easily swayed. Patch has been submitted. And if I get firebombed by the Society of Programmers Who Use Underscores In Their Property Names, I'm blaming you. Those guys are pissed off with me enough as it is.

# April 13, 2008 5:21 PM

Mark Lennox said:

will xpath work instead? I haen't tried that myself...

# April 14, 2008 7:23 AM

Scott said:

Does Document.getElementById("dto.JobName"); work?

# April 14, 2008 2:12 PM

Kyle Baley said:

@Mark: How do you mean? Selecting the item from the HTML document using an XPath statement? If so, I kinda like my workaround better.

@Scott: Apparently so. The following works in both IE and Firefox:

<html>

<head>

   <script type="text/javascript">

       function moo( )

       {

           alert( document.getElementById( "noDot" ).innerHTML );

           alert( document.getElementById( "with.dot" ).innerHTML );

       }

   </script>

</head>

<body onload="moo( )">

   <div id="noDot">No dot</div>

   <div id="with.dot">With dot</div>

</body>

</html>

# April 14, 2008 2:26 PM

Christopher Steen said:

ASP.NET ASP.NET Dynamic Data Preview Available [Via: ScottGu ] Putting ASP.NET Dynamic Data into Context...

# April 14, 2008 11:03 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!