New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote and depends bug #431
Comments
I also encountered this issue, it's not a new thing as I see posts referencing the same scenario from at least 3 years ago. I did find a very acceptable workaround, but I'd rather not use it if the underlying code is possibly going to be "fixed" which would likely break this solution. The workaround I found is to nest the standard remote: properties under a property named param:. If the depends: function returns true, it will reference the properties as you would expect. Here's a sinippet of what my rule ends up looking like: rules: {
'appointment_type[name]': {
required: true,
remote: {
param: {
url: "/hw/validate/appointment_type/name.json",
data: {
'appointment_type[id]': "5"
}
},
depends: function() {
return $("#appointment_type_name").val() !== "Adjustment2";
}
}
}, As far as I can tell this is a 100% solution to the issue, with the only downside being the possibility future versions of the validation plugin would change this behavior. |
Wow, this is a nice workaround, I'll try it as soon as possible, thanks! Edit: this is working like a charm. |
Thanks, thats working cool! |
Hey thanks! Awesome workaround. |
Awesome! Just what I needed. |
awesome |
As far as I can tell, this is a documentation issue. I've created #981 to keep track of that. |
Hey thanks! |
It works perfectly! |
Hi there. Any idea if this solution is still valid because it doesn't seem to call the AJAX/Remote code when the url is placed within the param. |
Works for me. Thx |
Thank you very much! |
Solved my headache. Thank you :) |
Works! |
Thank you @shakerlxxv it helped me a lot |
param data: attribute will not dynamically set. it will set only while when document is ready. |
When you try to remote with depends, the AJAX's parameters are not taken.
The simple test case below illustrates it:
The call is made via GET to the page's url, not in POST to 'myurl'.
The text was updated successfully, but these errors were encountered: