new jQuery selectors

Apr 20, 2010 at 12:55 PM

Until you have a jQuery plugin for handling the error messages disappearing with the templating, any idea how they should be re-written to match the DOM?

Apr 20, 2010 at 1:24 PM
It completely depends on the HTML template that you use. You can send me your generated HTML if you'd like. I would recommend watching some jQuery videos and reading some documentation. Once you have a handle on the fundamentals of jQuery, you'll find it's very easy to write the JavaScript that you need.
Apr 20, 2010 at 1:31 PM

Assume it is the one that you used with your TestController example ...

Apr 22, 2010 at 6:12 PM

<tr>      <th valign="top">        <label class="MvcDynamicFieldPrompt" for="MvcDynamicField_03b8c7118b604b31afa57029132aeca8">Enter your full name:</label>      </th>      <td valign="top">        <label class="MvcDynamicFieldError" for="MvcDynamicField_03b8c7118b604b31afa57029132aeca8">Your full name is required</label>        <input id="MvcDynamicField_03b8c7118b604b31afa57029132aeca8" name="MvcDynamicField_03b8c7118b604b31afa57029132aeca8" type="text" value="" />      </td>    </tr>

Apr 29, 2010 at 10:51 AM

Any thoughts on this? Failing that, how is the plugin coming along?

I have just found a related issue and not sure if you are aware of it. Regarding the jQuery you have:

$('div.MvcFieldWrapper :input').focus(function() {                $(this).closest('div.MvcFieldWrapper').children('label.MvcDynamicFieldError').fadeOut();            });

This works fine in the solution but when I actually deploy it on IIS7 it doesn't make the error messages disappear on clicking the radiobuttons which is very odd. The other controls are fine. Have you come across this?

Apr 29, 2010 at 1:11 PM

Ignore that related issue, there's nothing wrong with your jQuery. My mistake.

Still interested in how it should be adjusted for templates though ...

Apr 29, 2010 at 3:10 PM
I haven't forgotten about this, but I have had some other obligations that have kept me busy lately. I will post some javascript this weekend or sooner.
Apr 29, 2010 at 11:55 PM
Sorry again for the delay. A simple change to 2 selectors was all that it took.
$('div.MvcFieldWrapper :input').focus(function() {
Became this:
$(':input').focus(function() {
Get the updated code in changeset 79364c5888eb.
Apr 30, 2010 at 6:31 PM

Great thanks. Not that when you want to make things visible using jQuery, .slideDown() and such functions do not always work on all browsers (including IE) so stick with the more basic .show()

Apr 30, 2010 at 6:42 PM
Glad to help. Thanks for the tip.