jquery-validation icon indicating copy to clipboard operation
jquery-validation copied to clipboard

Attach jquery within onRendered don't work

Open thearabbit opened this issue 8 years ago • 3 comments
trafficstars

I try, but some time don't work. Can't find $( "#example-form" ) (maybe attach before rendered).

Template.exampleForm.onRendered( function() {
  $( "#example-form" ).validate();
});

And then

Template.exampleForm.onRendered( function() {
  Meteor.setTimeout(function () {
           $( "#example-form" ).validate(); 
   }, 1000);
});

I have many for this problem of attachment jquery. Please help me.

thearabbit avatar Jan 14 '17 09:01 thearabbit

@thearabbit can you share your template HTML/markup? If you have any loading state in your template, it's possible that it's blocking the rendering of the form meaning that jQuery Validation cannot attach to it.

themeteorchef avatar Jan 16 '17 13:01 themeteorchef

thanks for your reply. oh sometime I use jquery Block UI, to block until the method got the result from server (use it in onCreated). It have problem or not?

thearabbit avatar Jan 16 '17 14:01 thearabbit

@thearabbit yes, this would cause a problem sometimes. If the <form></form> element having validation attached to it isn't visible in the DOM when your onRendered() function fires, then the validation won't work. If you can, pull the <form></form> element outside of your Block UI code so it's always visible (but its contents still show/hide based on your Block UI code).

themeteorchef avatar Jan 18 '17 22:01 themeteorchef