Read the statement by Michael Teeuw here.
Input field forces restart instead of update
-
Hi, I’ve just recently started with using raspberry pi and started with magic mirror.
I created a module through the template provided, with the use for adding an input field.I’ve been running into an issue of each time I press the enter key on the keyboard after entering a text in the filed or just having the empty field, the magic mirror restarts itself and I’m back to square one.
This is the code to create it iside the
getDomfunction:getDom: function() { var self = this; var wrapper = document.createElement("div"); self.config.form = document.createElement("form"); self.config.inputbox = document.createElement("input"); self.config.dropdownFields = document.createElement("select"); self.config.inputbox.setAttribute("type", "text"); self.config.form.appendChild(self.config.inputbox); self.config.form.appendChild(self.config.dropdownFields); wrapper.appendChild(self.config.form); // If this.dataRequest is not empty if (this.dataRequest) { self.getInput(); self.getFields(); } return wrapper; },Every time I hit enter it refreshes the whole page.
I’ve also added code for action on change:
self.config.inputbox.onchange = function() {self.setVisibile(self.config.dropdownFields)};
but even without this code it still
The good news is I can notice that theonchangefunction works (just before everything is restarted).Does anyone have any idea why this is like that, do I need to change some settings I am not aware of??
Thank you for any feedback.
-
@joncedimov If it’s the [enter] causing problems, you may need to override/disable the
onsubmitevent listener for the form. It may be that you’re submitting the form, MM has no idea what to do with that data, and so simply displays (reloads) the same page. -
Thanks @ninjabreadman, that seems to do the trick for now :)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login