Skip to content
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

validationEngine('hide') giving Script Error #315

Closed
chintushah46 opened this issue Mar 23, 2012 · 19 comments
Closed

validationEngine('hide') giving Script Error #315

chintushah46 opened this issue Mar 23, 2012 · 19 comments

Comments

@chintushah46
Copy link

Version: 2.5.2

$('#txtSoldDate').validationEngine('hide'); is giving me script error called
"TypeError: options is undefined"
@
$('.'+closingtag).fadeTo(options.fadeDuration, 0.3, function() {
in hide function.

@chintushah46
Copy link
Author

Same is @ demos/demoValidators in yr package.
just click on Validate sport1 select and then click on Close favorite sport 1 prompt.

Please help me !!!!

@orefalo
Copy link
Collaborator

orefalo commented Mar 23, 2012

works fine for me (Chrome). get the latest from master

@chintushah46
Copy link
Author

not working for me on firefox

@chintushah46
Copy link
Author

here is the example of my issue...

http://chintan-re2012.kwetoo.com/test/index.php

select the sold from Property Status, then u can see 2 new text boxes,
just traverse through them, then u can see 2 pop ups,
now change any other value from Drop down there u can see the script error and pop ups are still there.

following is my code in js file

if ( $('#txtSalePrice').is(':visible') )
jQuery('#txtSalePrice').validationEngine('hide');
if ( $('#txtSoldDate').is(':visible') )
jQuery('#txtSoldDate').validationEngine('hide');

@orefalo
Copy link
Collaborator

orefalo commented Mar 23, 2012

got it. wasn't running the right steps. yep looks like an issue.

@gRoberts84
Copy link
Contributor

Hi all,

I've just posted and closed (due to seeing this) an issue related to this, when calling hidePrompt.

#321

It's due to $.fn.validationEngine assuming that the selector is a form, but hidePrompt and possibly other methods are meant to select the input that the prompt is related to.

@gRoberts84
Copy link
Contributor

With the following code, I assume hidePrompt is no longer required.

 hide: function() {
     var form = this;
     var closingtag;
     if($(this).is("form")){
         closingtag = "parentForm"+methods._getClassName($(this).attr("id"));
     }else{
         closingtag = methods._getClassName($(this).attr("id")) +"formError";
         form = $($(this).get(0).form); // Get the element's associated form.
     }
     // If for any reason, the form does not exist, don't bother carrying on.
     if(form.length == 0) return this;
     var options = form.data('jqv');
     $('.'+closingtag).fadeTo(options.fadeDuration, 0.3, function() {
         $(this).parent('.formErrorOuter').remove();
         $(this).remove();
     });
     return this;
 },

But it works for me.

@orefalo
Copy link
Collaborator

orefalo commented Mar 28, 2012

yes, I need to fix it - didn't get time just yet.

Another option to your fix, would be to look for the parent form

@gRoberts84
Copy link
Contributor

My original code used $(this).closest('form') but I thought that could/might cause problems so I used the form attached to the element (native javascript).

@orefalo
Copy link
Collaborator

orefalo commented Mar 28, 2012

Why would $(this).closest('form') cause problems ? We use it in other parts of the code

@gRoberts84
Copy link
Contributor

When I wrote it, it seemed like there might be a reason behind me saying
that, but now... it's obvious that either way will work ;)

On 28 March 2012 15:43, Olivier Refalo <
reply@reply.github.com

wrote:

Why would $(this).closest('form') cause problems ? We use it in other
parts of the code


Reply to this email directly or view it on GitHub:

#315 (comment)

@orefalo
Copy link
Collaborator

orefalo commented Mar 28, 2012

I would rather go with closest(), it's easier to get. Would you mind submitting a pull req ?

@gRoberts84
Copy link
Contributor

As requested. Within my comments, I also mentioned that you "could" possibly use closest for the rest of your var form = this; lines.

cheers

@glennjacobs
Copy link

I've added the fix as described because I wanted to do the following

$('#address, #city, #zip').validationEngine('hidePrompt');

However, it only hides the first prompt and ignores the others. Sorry not sure if I should have started a new thread or not as it is kinda of related.

@glennjacobs
Copy link

FYI, I modified my code to work as follows

    /**
    * Closes all error prompts on the page
    */
    hidePrompt: function() {
        var form = $(this).closest('form');
        var options = form.data('jqv');

        this.each(function(){

            var promptClass =  "."+ methods._getClassName($(this).attr("id")) + "formError";
            $(promptClass).fadeTo(options.fadeDuration, 0.3, function() {
                $(this).parent('.formErrorOuter').remove();
                $(this).remove();
            });

        });

        return this;
    },

@orefalo
Copy link
Collaborator

orefalo commented Mar 28, 2012

@neondigital this is out of scope, it's an enhancement

@gRoberts84 thank you

Bug is fixed

@orefalo orefalo closed this as completed Mar 28, 2012
@chintushah46
Copy link
Author

Thanks !!!

@Isarien
Copy link

Isarien commented Mar 29, 2012

Thanks a lot !

@orefalo
Copy link
Collaborator

orefalo commented Apr 5, 2012

FYI: I recently removed the hidePrompt & validateField methods

@neondigital I will be working on the multifield feature soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants