Kyle Baley - The Coding Hillbilly

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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


Posted 04-12-2008 10:59 PM by Kyle Baley
Filed under: ,

[Advertisement]

Comments

Ken Egozi wrote re: jQuery and the ConventionController
on 04-13-2008 2:09 AM

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 ..

Joshua Flanagan wrote re: jQuery and the ConventionController
on 04-13-2008 4:34 PM

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!

Kyle Baley wrote re: jQuery and the ConventionController
on 04-13-2008 5:21 PM

@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.

Mark Lennox wrote re: jQuery and the ConventionController
on 04-14-2008 7:23 AM

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

Scott wrote re: jQuery and the ConventionController
on 04-14-2008 2:12 PM

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

Kyle Baley wrote re: jQuery and the ConventionController
on 04-14-2008 2:26 PM

@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>

Christopher Steen wrote Link Listing - April 14, 2008
on 04-14-2008 11:03 PM

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

Add a Comment

(required)  
(optional)
(required)  
Remember Me?