Skip to content

Commit

Permalink
netteForms.js: fixed issue with button type=submit with html [Closes #…
Browse files Browse the repository at this point in the history
…137]

If button have some HTML inside, like <i class="icon icon-send"></i> and user click on I instead of button, nette thinks there is no submittedBy button, that is not true, as <i> have parent button element, so we need to go thru DOM tree, to check if the button isnt parent of clicked element.
  • Loading branch information
Radovan Kepák authored and dg committed Oct 25, 2016
1 parent 46caa19 commit 6318da7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/assets/netteForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,12 @@ Nette.initOnLoad = function() {

Nette.addEvent(document.body, 'click', function(e) {
var target = e.target || e.srcElement;
if (target.form && target.type in {submit: 1, image: 1}) {
target.form['nette-submittedBy'] = target;
while (target) {
if (target.form && target.type in {submit: 1, image: 1}) {
target.form['nette-submittedBy'] = target;
break;
}
target = target.parentNode;
}
});
});
Expand Down

0 comments on commit 6318da7

Please sign in to comment.