GiriB / django-gentelella

gentelella-admin-template modified for Django
MIT License
370 stars 165 forks source link

Get parsley error #2

Closed marcosguerrini closed 6 years ago

marcosguerrini commented 7 years ago

I get this warning and error in every pages that use this gentelella adaptation for django.

utils.js:87 You must bind Parsley on an existing element. warn @ utils.js:87

Uncaught TypeError: Cannot read property 'isValid' of undefined at validateFront (custom.js:999) at HTMLDocument. (custom.js:975) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at Function.ready (jquery.min.js:2) at HTMLDocument.J (jquery.min.js:2)

even if i use the plain_page.html get that error.

anglvictor commented 7 years ago

any updates on this issue?

drjmcauliffe commented 7 years ago

Coming back to this after sometime... I fixed this by wrapping the if-else block

if (true === $('#demo-form2').parsley().isValid()) {
    $('.bs-callout-info').removeClass('hidden');
    $('.bs-callout-warning').addClass('hidden');
} else {
    $('.bs-callout-info').addClass('hidden');
    $('.bs-callout-warning').removeClass('hidden');
}

... in an if statement to check demo-form2 exists in the page, as follows:

if ($('#demo-form2').length > 0 ) {
    if (true === $('#demo-form2').parsley().isValid()) {
        $('.bs-callout-info').removeClass('hidden');
        $('.bs-callout-warning').addClass('hidden');
    } else {
        $('.bs-callout-info').addClass('hidden');
        $('.bs-callout-warning').removeClass('hidden');
    }
}

No more error!

joseph9991 commented 5 years ago

Hey guys. The above solution works. Just make sure you delete your cache and then try again.