Doubled validation popup from NetteForms - please help #411
-
Hi, I was working on update from Naja 1.8.3 to latest and now, I´m getting doubled popups from NetteForms validation-ofter clicking send, it shows validation window, clicking ok clears one and there is second one, same, under the first one. No idea why. Tried switching order of Naja / NetteForms loading in Webloader-no success. I´ve actually updated because of problems with TreeView in Contributte/Datagrid in my admin, that problem seems to be solved by update, but, got the doubled validation pop-ups instead. Form has ajax class. I have this in Webloader: And front.js contents little to nothing: "use strict";
naja.initialize();
// Naja: run after ajax update
naja.snippetHandler.addEventListener('afterUpdate', (event) => {
// todo (re)initialize stuff
// Activate scrollspy to add active class to navbar items on scroll
$('body').scrollspy({
target: '#mainNav',
offset: 56,
});
});
// Naja: handle snippets on 4xx errors
naja.addEventListener('error', ({xhr, response}) => {
if ((xhr.status >= 400 && xhr.status <= 499) && response.snippets) {
naja.snippetHandler.updateSnippets(response.snippets);
}
});
(function($) {
// smart menus init
jQuery.SmartMenus.Bootstrap.init();
})(jQuery); It worked with Naja 1.8.3 this way: "use strict";
document.addEventListener('DOMContentLoaded', naja.initialize.bind(naja));
naja.addEventListener('load', () => {
// todo (re)initialize stuff
// Activate scrollspy to add active class to navbar items on scroll
$('body').scrollspy({
target: '#mainNav',
offset: 56,
});
});
// handle snippets on 4xx errors
naja.addEventListener('error', ({xhr, response}) => {
if ((xhr.status >= 400 && xhr.status <= 499) && response.snippets) {
naja.snippetHandler.updateSnippets(response.snippets);
}
});
(function($) {
// smart menus init
jQuery.SmartMenus.Bootstrap.init();
})(jQuery); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, sorry I didn't notice this earlier I've submitted a pull request that should fix this upstream: nette/forms#342 In the meantime, one way around this issue is to disable the automatic init-on-load behaviour of netteForms by invoking the following script before loading netteForms.js: window.Nette.noInit = true; |
Beta Was this translation helpful? Give feedback.
Hi, sorry I didn't notice this earlier☹️ as I've explained on Nette forum, Naja since 3.2 listens for the form's
submit
event, same as netteForms. If the netteForms script is initialized before Naja, it validates the form first but then hands it over to Naja which runs the validation once again.I've submitted a pull request that should fix this upstream: nette/forms#342
In the meantime, one way around this issue is to disable the automatic init-on-load behaviour of netteForms by invoking the following script before loading netteForms.js: