2 Replies Latest reply on Jul 15, 2013 2:20 AM by David Miller

    Set button href

    David Miller

      I am trying to set a button href.  I call the following function from the controller which sets the button text and the href.  The setting of the text works but the href isn't being set.

       

      Any ideas why this isn't working in Rho?

       

                  function setOverrideLocCompBtn ()

                  {

                    $('#locationComplete .ui-btn-text').text("Update Product");

                    $('#locationComplete').attr("href", "/app");

                  }

       

            <div id="locationComplete">

                 <a href="/app/AppData/enter_location" data-role="button" data-ajax="false" id="LocationComplete">Location Complete</a>

                </div>

        • Re: Set button href
          Pietro Francesco Maggi

          Hi David,

          just use Chrome dev tools and inspect what you're trying to do.

           

          You'll discover that it's not a Rho issue, but having the same id in the <a> and in the <div>. Your code it's adding an href attribute to the <div>.

           

          Try using something like:

          <html>

          <head>

          <script src="./jquery-1.6.4.min.js" type="text/javascript"></script>

          <script src="./jquery.json-2.3.min.js" type="text/javascript"></script>

          <script type="text/javascript" charset="utf-8" src="./jquery.mobile-1.0.1.min.js"></script>

          <link rel="stylesheet" href="./jquery.mobile-1.0.1.min.css">

          <script>

                  function setOverrideLocCompBtn ()

                        {

                        $('#locationComplete .ui-btn-text').text("Update Product");

                        $('#locationComplete .ui-btn').attr("href", "/app");

                      }

          </script>

          </head>

          <body>

                <div id="locationComplete">

                       <a href="/app/AppData/enter_location" data-role="button" data-ajax="false" id="LocationComplete">Location Complete</a>

                      </div>

          </body>

          </html>

           

          Best regards

          Pietro

          1 of 1 people found this helpful
            • Re: Set button href
              David Miller

              Hi Pietro

               

              Many thanks indeed.

               

              This was the syntax I ended up with:

               

                    <div id="locationComplete">

                      <a href="/app/AppData/enter_location" data-role="button" data-ajax="false" id="LocnCompBtn">Location Complete</a>

                    </div>

               

                          function setOverrideLocCompBtn ()

                          {

                            $('#locationComplete .ui-btn-text').text("Update Product");

                            $('#locationComplete a').attr('href', '/app');           

                          }

               

              You were right, the <div> was being set, not <a>.  So I needed the additional qualification of '#locationComplete a'