Answer the question
In order to leave comments, you need to log in
Why is sambit click not handled?
Hello. Here is a function. By clicking on the link, it uses the htm5 isporia api (this part works), and if it is on the button, it should call this function https://gist.github.com/bullgare/5336154 (the sambit check part does not work)
window.onload = function () {
var FullList = document.getElementById('contentHolder');
FullList.addEventListener('click', Content, false);
function Content(e) {
var link = e.target;
//если нажали на ссылку
if (link.nodeName.toLowerCase() === 'a') {
getContent(link, true);
e.preventDefault();
}
//если нажали на самбит
if (link.nodeName.toLowerCase() === 'submit') {
alert(serialize(document.forms[0]));
}
}
;
};
Answer the question
In order to leave comments, you need to log in
Because nodeName is the name of the node, and submit is not a tag, but an attribute value.
And you need to check not click on the button, about submitting the form.
document.addEventListener('DOMContentLoaded', function () {
var FullList = document.getElementById('contentHolder');
FullList.addEventListener('click', function (e) {
if (e.target.nodeName == 'A') {
e.preventDefault();
getContent(e.target, true);
}
});
FullList.addEventListener('submit', function (e) {
if (e.target.name == 'Имя_Формы') { // При наличии нескольких форм внутри FullList
e.preventDefault();
console.log(serialize(e.target));
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question