MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

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 getDom function:

    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");    
    	// If this.dataRequest is not empty
    	if (this.dataRequest) {
    	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 the onchange function 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 onsubmit event 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 🙂

Log in to reply