Question

I'm trying to add on the fly validators, but seems like parsley is not even remotely considering the statements, without even leaving errors in the console. here's my scenario

user clicks on a checkbox and then:

if(!$scope.data.contest.prizes[1].enabled)
{
    $( '#edit_contest' ).parsley( 'removeItem', '#prz2_it_ttl' );
} else {
    $( '#edit_contest' ).parsley( 'addItem', '#prz2_it_ttl' );
}

I've also tried to give the jquery object $("#myelement")

$( '#edit_contest' ).parsley( 'addItem', $('#prz2_it_ttl') );

Or, I've tried to wrap it around a destroy/create statement

$( '#edit_contest' ).parsley('destroy');
$( '#edit_contest' ).parsley( 'addItem', $('#prz2_it_ttl'));
$( '#edit_contest' ).parsley();

this didn't event change a thing.

Était-ce utile?

La solution

turns out that the reason behind this odd behavior is that one of the ids mentioned in the add/removeItem where misspelled but the log was pointing to the wrong line.

I had this

$( '#edit_contest' ).parsley( 'removeItem', '#prz2_it_ttl' );
$( '#edit_contest' ).parsley( 'removeItem', '#prz2_en_ttl' );
$( '#edit_contest' ).parsley( 'removeItem', '#prz2_it_des' );
$( '#edit_contest' ).parsley( 'removeItem', '#prz2_en_des' );

and the error was pointing to the 1st line when the real misspell was on the 4th line. after discovering and fixing that, everything started to work like a charm (more or less). so the moral of the story is: ALWAYS double check all the ids before doing anything else in your debugging routine.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top