guillaumepotier / Parsley.js

Validate your forms, frontend, without writing a single line of javascript
http://parsleyjs.org
MIT License
9.05k stars 1.32k forks source link

Error message above input field #979

Closed isAlmogK closed 8 years ago

isAlmogK commented 8 years ago

Just updated to the lastest stable version of Parsley.JS and the biggest change that I'm now getting in my app is that the error message are now above my input fields any reason why this is happening with the latest version

screen shot 2015-09-17 at 1 16 57 am

marcandre commented 8 years ago

I'm sorry about the issue you are having. The error messages should indeed show up at the same place.

I imagine you are changing the error message selector somehow? Can you provide that code?

isAlmogK commented 8 years ago

The html is straightforward it might the template or bootstrap

<div class="col-lg-3">
<br>
<label class="control-label" for="food-type">{{mf "foodType" "Food Type"}}</label>
 <br>
<select style="width: 100%" id="food-type" name="food-type"  data-parsley-group="step1" required>
 <option></option>
 </select>
</div>
isAlmogK commented 8 years ago

So it looks like it's only happening to the select2 dropdowns I'm guessing that's causing the issue. I tried setting a custom UI but it did not help

data-parsley-class-handler="#custom-parsley-error"
<span id="custom-parsley-error"></span>
marcandre commented 8 years ago

I'd very much like to know the source of the change.

BTW, which is the latest "stable" version you are referring to?

isAlmogK commented 8 years ago

I'm using 2.1.3 but also tested it out with 2.2.0-rc1 same issue, been trying to debug from what I can tell ul element is always above the select2 element

screen shot 2015-09-17 at 2 27 25 am

Quantity is a regular text input it's fine there but Quality is a select2 dropdown

marcandre commented 8 years ago

Oh, ok, I'm happy to see there's no change between 2.1 and 2.2, that's what I was worried about.

What's the old version you were using that was putting the error where you wanted it?

Any way to know the actual DOM hierarchy around that <select> (before and after)?

isAlmogK commented 8 years ago

Verson v2.0.5 was fine and did not have this issue

marcandre commented 8 years ago

Looking at the Changelog, you'll see that "Error containers are created only the first time they are needed". It's likely that the lib you're using for your select is loaded after Parsley. In 2.0, the error container was created, then the lib was modifying the <select>, but now the error container is created afterwards and that doesn't give you the result you want?

marcandre commented 8 years ago

A quick way to check if that's the case: with 2.0.x, change the load order of your select library and parsley. If I'm right, then you'll probably need to tweak the error selector for these kinds of inputs.

isAlmogK commented 8 years ago

That might be the issue as I'm using Meteor but I can't change the order select2 is loaded is there any other way to fix this how can I modify the error selector?

marcandre commented 8 years ago

Mmm, looks like errors-container is not documented. It can be a jQuery selector, or a function returning a jQuery set of where to insert the error wrapper. To use the function, you have to set the option via JS, for example:

$('.my-input').parsley().options.errorsContainer = function(instance) { return $('...') }
marcandre commented 8 years ago

What's the status on this?