sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Executing one call_back executes another.

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 6 Posters 617 Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sdmitchS Offline
      sdmitch
      last edited by

      @tig said:

      We don't see you js or html... or most of your rb.
      So when is the callback "InitializeForm" called ?
      If it is called as the html is ready then if you reload the page after the "Select" button is clicked then that callback does re-run ?
      The values do default so I suspect something is reloading the page's html ?

      "initializeForm" is called when the html is loaded but I am not knowingly doing anything that would cause the html to reload when the select button is clicked.


      Select by Attribute_WD.rb

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        have you got a link for the model?

        It has no values for the models I've tried, and it would be easier if we look at the same one...

        if you remove value="select" from the button attributes does it work correctly?

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • sdmitchS Offline
          sdmitch
          last edited by

          @driven said:

          have you got a link for the model?

          It has no values for the models I've tried, and it would be easier if we look at the same one...

          if you remove value="select" from the button attributes does it work correctly?

          john

          No change with value="select" removed.

          Here is the model provided to me that I have been testing with.


          scaffold with attributes_v14.skp

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            In HTML the <script> code block normally goes in the <header>, NOT the <body> - try moving it into there and retest...

            As it is window.location='skp:InitializeForm@'; is run whenever the HTML body loads.
            Currently your code makes a new WebDialog for @dlg afresh every time your tool is run, perhaps adding unless @dlg after it would at least prevent that ?

            TIG

            1 Reply Last reply Reply Quote 0
            • sdmitchS Offline
              sdmitch
              last edited by

              @tig said:

              In HTML the <script> code block normally goes in the <header>, NOT the <body> - try moving it into there and retest...

              As it is window.location='skp:InitializeForm@'; is run whenever the HTML body loads.
              Currently your code makes a new WebDialog for @dlg afresh every time your tool is run, perhaps adding unless @dlg after it would at least prevent that ?

              Moving script to the header only caused the select list to remain empty. Adding the unless caused the InitializeForm to not run at all.

              Why InitializeForm is run every time a button is clicked is still a mystery for now. I have managed to overcome the problems that caused.

              Nothing is worthless, it can always be used as a bad example.

              http://sdmitch.blogspot.com/

              1 Reply Last reply Reply Quote 0
              • M Offline
                MSP_Greg
                last edited by

                @sdmitch said:

                "initializeForm" is called when the html is loaded but I am not knowingly doing anything that would cause the html to reload when the select button is clicked.

                Remove the form tags. Forms have some odd default behavior, in this case, reloading the html...

                Attached an rb file with some changes --

                1. Uses 'html is loaded' for callback
                2. Changed 'InitializeForm' execute_script statements to pass arrays

                I did remove the top of the code.

                Greg


                Select by Attribute_WD 1.1.rb

                1 Reply Last reply Reply Quote 0
                • sdmitchS Offline
                  sdmitch
                  last edited by

                  @msp_greg said:

                  @sdmitch said:

                  "initializeForm" is called when the html is loaded but I am not knowingly doing anything that would cause the html to reload when the select button is clicked.

                  Remove the form tags. Forms have some odd default behavior, in this case, reloading the html...

                  Attached an rb file with some changes --

                  1. Uses 'html is loaded' for callback
                  2. Changed 'InitializeForm' execute_script statements to pass arrays

                  I did remove the top of the code.

                  Greg

                  Greg, Thanks for help. It seems that the form tags were the majority of the problem.

                  Nothing is worthless, it can always be used as a bad example.

                  http://sdmitch.blogspot.com/

                  1 Reply Last reply Reply Quote 0
                  • tt_suT Offline
                    tt_su
                    last edited by

                    Did you make that buttom a Submit button? By default I think that will make a POST request to the same page it is on. You need to either capture that event and prevent the default action, or make the button a non-submit: <input type="button"> or <button></button>.

                    1 Reply Last reply Reply Quote 0
                    • sdmitchS Offline
                      sdmitch
                      last edited by

                      @tt_su said:

                      Did you make that buttom a Submit button? By default I think that will make a POST request to the same page it is on. You need to either capture that event and prevent the default action, or make the button a non-submit: <input type="button"> or <button></button>.

                      No, I just removed the <form></form> and that fixed the "problem".

                      Nothing is worthless, it can always be used as a bad example.

                      http://sdmitch.blogspot.com/

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        That would do the same thing - the <form> element usually have the URL to which to submit to. Without a parent <form> the submit button had no default action.

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement