Skip to contentSkip to conversation

web/search.{js, php}: pass the event to the submit handler

PATCH New Victor Huesca 3 participants 3 messages Aug 26, 2019 – Sep 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 web/search.{js, php}: pass the event to the submit handler

Some web-browsers do not define the global event object on functions callback (see [1]). This cause an 'undefined event' error on the search page. Passing the event argument from the function caller fix this (at least it does on Firefox ESR 60.0.8).

[1] http://buildroot-busybox.2317881.n4.nabble.com/New-search-features-on-autobuild-buildroot-org-tt230624.html

---
 web/search.js  | 2 +-
 web/search.php | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
web/search.js +1 -1
index cf52478..d624ade 100644
@@ -1,4 +1,4 @@
-function submitForm() {
+function submitForm(event) {
     // Do not send the form
     event.preventDefault();
 
web/search.php +1 -1
index bcdd62e..821308f 100644
@@ -7,7 +7,7 @@ bab_header("Buildroot tests - Search page");
 <script type='text/javascript' src="search.js"></script>
 
 
-<form action="index.php" method="get" onsubmit="submitForm()">
+<form action="index.php" method="get" onsubmit="submitForm(event)">
     <label>
         <span>Submitter:</span>
         <input type="text" name="submitter" placeholder="Submitter">
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 web/search.{js, php}: pass the event to the submit handler

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Victor" == Victor Huesca <[email protected]> writes:

Some web-browsers do not define the global event object on functions callback (see [1]). This cause an 'undefined event' error on the search page. Passing the event argument from the function caller fix this (at least it does on Firefox ESR 60.0.8).

[1] http://buildroot-busybox.2317881.n4.nabble.com/New-search-features-on-autobuild-buildroot-org-tt230624.html

Thanks!

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 web/search.{js, php}: pass the event to the submit handler

In reply to Victor Huesca
Quoted 5 lines · On Mon, 26 Aug 2019 14:14:05 +0200 Victor Huesca <[email protected]>…

Some web-browsers do not define the global event object on functions callback (see [1]). This cause an 'undefined event' error on the search page. Passing the event argument from the function caller fix this (at least it does on Firefox ESR 60.0.8).

Quoted 7 lines

[1] http://buildroot-busybox.2317881.n4.nabble.com/New-search-features-on-autobuild-buildroot-org-tt230624.html

---
 web/search.js  | 2 +-
 web/search.php | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Applied to buildroot-test, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com