new jQuery selectors

Apr 20, 2010 at 11:55 AM

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?

Coordinator
Apr 20, 2010 at 12: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 12:31 PM

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

Apr 22, 2010 at 5: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 9: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 12: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 ...

Coordinator
Apr 29, 2010 at 2: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.
Coordinator
Apr 29, 2010 at 10:55 PM
Sorry again for the delay. A simple change to 2 selectors was all that it took.
 
This:
$('div.MvcFieldWrapper :input').focus(function() {
    $(this).closest('div.MvcFieldWrapper').children('label.MvcDynamicFieldError').fadeOut();
});
 
 
Became this:
$(':input').focus(function() {
    $(this).closest('td').children('label.MvcDynamicFieldError').fadeOut();
});
 
Get the updated code in changeset 79364c5888eb.
Apr 30, 2010 at 5: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()

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