ngduc / Thin-PHP-Framework

A micro web framework - lightweight and flexible open source PHP5 MVC framework
http://www.thinphp.com
Other
41 stars 17 forks source link

[JS][thinphp.js]setFormError - selection of the fmsg span #12

Closed bmaingret closed 12 years ago

bmaingret commented 12 years ago

Hi, I don't know if it is the behavior researched, but when you put :

  1. $(formId+' :input[name='+fieldName+'] ~ span.fmsg').html(' '+errMsg+' ');
  2. $(formId+' :input[name='+fieldName+'] ~ span.fmsg').fadeIn('slow'); You will change every fmsg following the fieldName input. Perhaps it would be better to put
ngduc commented 12 years ago

Good catch! You are right. According to jQuery syntax: "~" is the Next Siblings Selector (“prev ~ siblings”) - selects all sibling elements that follow after the "prev" element, have the same parent, and match the filtering "siblings" selector.

So, input field & its "fmsg" span should be together under their parent.

This is the demo page & I think it works with multiple errors because it set errors from top, down. http://demo.thinphp.com/contact-us

I will investigate more & fix it. Thanks again :)

ngduc commented 12 years ago

Fixed in this commit: https://github.com/ngduc/Thin-PHP-Framework/commit/a920978bdc5f2fd04d27bfef4f8b427d1aa3b28f

Thanks again seven-up! :)

btw, a new version has just been released v0.55