Announcement

Collapse
No announcement yet.

how do i refresh a liquid tag without refreshing the page

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

    how do i refresh a liquid tag without refreshing the page

    i have two liquid tags. I want the first to influence the second

    how can i do this without posting back to the plugin
    Mark

    HS3 Pro 4.2.17.0
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3| Ultra1Wire3 | RFXCOM | NetCAM | HS MyQ | BLRadar | BLDenon | Jon00 Charting | Jon00 Links
    Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

    #2
    But to refresh the liquid tags you do need to post back to get the new value?

    Comment


      #3
      I was hoping to get the value from select 1 and submit that back to the liquid tag as an input
      Mark

      HS3 Pro 4.2.17.0
      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3| Ultra1Wire3 | RFXCOM | NetCAM | HS MyQ | BLRadar | BLDenon | Jon00 Charting | Jon00 Links
      Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

      Comment


        #4
        Can you check the generated html to see what's in place for the liquid tag?

        Comment


          #5
          could you post an example of what you are trying to do, not sure I follow. Liquid tags are server side converted into HTML, once that is done, not sure how you can do something with a post back or why you would even do so, because now your PI is "server side", you can generate any HTML you want in your response and update any div

          Comment


            #6
            Maybe I'll ask different questions...

            I need to dynamically build a select element where the options change based on some other element on the html page

            (1) how do you decide if you do this with a liquid tag and doing a page refresh versus updating a div using ajax?

            (2) do you build select elements using the hs4 selectlistview class (there seems to be some bugs in this class) or just write standard html?

            Mark

            HS3 Pro 4.2.17.0
            Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
            Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3| Ultra1Wire3 | RFXCOM | NetCAM | HS MyQ | BLRadar | BLDenon | Jon00 Charting | Jon00 Links
            Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

            Comment


              #7
              I do everything in C# code. I have single template file and only replace the plugin name and page name.

              And plugin provides three functions: 'GetTitle', 'GetHTML' and 'GetJS' .

              And I do use hs4 selectlistview class

              Click image for larger version

Name:	Screenshot 2021-11-08 235538.png
Views:	108
Size:	74.1 KB
ID:	1506967

              Comment


                #8
                Example:

                Click image for larger version

Name:	Screenshot 2021-11-08 235312.png
Views:	104
Size:	52.2 KB
ID:	1506969

                Comment


                  #9
                  Alex, thanks for posting; i think this will be helpful for others

                  have you found the selectlistview class doesn't generate the option keys correctly?

                  the below is hs4 generated code. I did not specify a zero for this option key. So when i post back, i need to regenerate the same option list just to get the correct option key based on the value (0).

                  Code:
                  <option value="0" selected="">Alert Alert  Module Alert: Alert  Module - Alert</option>
                  I think this is known issue; how do you work around this?
                  Mark

                  HS3 Pro 4.2.17.0
                  Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
                  Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3| Ultra1Wire3 | RFXCOM | NetCAM | HS MyQ | BLRadar | BLDenon | Jon00 Charting | Jon00 Links
                  Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

                  Comment


                    #10
                    Yeah, selectlistview is a bit of a mess (like most of HST code)... It stores only the indexes, not keys.

                    So you need to keep the original SelectListView, then from the SelectListView returned from postback you get the selected index, then you get the original string from the original view:

                    Click image for larger version

Name:	Screenshot 2021-11-09 004230.png
Views:	105
Size:	29.7 KB
ID:	1506980

                    Click image for larger version

Name:	Screenshot 2021-11-09 004325.png
Views:	104
Size:	43.3 KB
ID:	1506981

                    Comment


                      #11
                      And to keep the original SelectListView I have a map viewID => SelectListView

                      It also maps the view to the object and it's property - so when the postback is received - the map automatically updates the property value.

                      So the usage is pretty simple (but the internal code isn't) - i.e. when user selects the Language - the root.Language property is updated automatically:

                      pb.AddSelectListView("Language", root.Languages, root, nameof(root.Language));


                      Click image for larger version

Name:	Screenshot 2021-11-09 004629.png
Views:	110
Size:	118.8 KB
ID:	1506984

                      Comment


                        #12
                        Originally posted by mnsandler View Post
                        Maybe I'll ask different questions...

                        I need to dynamically build a select element where the options change based on some other element on the html page

                        (1) how do you decide if you do this with a liquid tag and doing a page refresh versus updating a div using ajax?

                        (2) do you build select elements using the hs4 selectlistview class (there seems to be some bugs in this class) or just write standard html?
                        You can do what Alex is doing, might be easiest but this would refresh the whole page, maybe not an issue. I do updates of div on client side using javascript code, maybe too complex, but I have a player/navigation function and reloading the page would be a no-no.

                        Comment

                        Working...
                        X