Announcement

Collapse
No announcement yet.

Removing old dialogs for input fields

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Removing old dialogs for input fields

    I use AJAX to update the plug-in configuration page. During this update I may add or remove input fields. If I remove a field, the dialog for entering the value for that field is not removed from the HTML DOM. This results in multiple dialogs with the same ID.

    See the attached image. The first password dialog is old, and the second is new. But because they have the same ID (generated by HomeSeer based on the ID of the field) the first one is shown to the user when they click the new password field.

    Should I do something in my code to ensure that dialogs for removed fields get cleaned up, or is this a bug in HomeSeer?

    #2
    The page generation stuff has a number of issue like this (another case, trying to embed a tabbed control in the config page is a bit problematic). I'd strongly suggest you show/hide the controls vs add/remove them. HS injects some script to manage the controls, so it gets upset when they aren't actually there.

    Comment


      #3
      Thanks. I will look into that.

      Comment


        #4
        it turns out that managing the visibility complicates things quite a bit. My plug-in supports multiple device types, and each device type has its own settings. But device types may share the ID of a field while having different rules for that field. For example: The password for device type A may not be longer than 8 characters, and the password for device type B may not contain certain characters. I would have to have both of these fields in the page, and hide or show them when the user selects another device type. As you cannot have 2 fields with the same ID, I also would have to qualify each field ID with a device type identifier.

        So I decided to simply force a browser refresh. Now I only have to add 1 line of code, and (in this case) the effect on the user experience is minor.

        Comment

        Working...
        X