0 Replies Latest reply on May 18, 2016 5:40 AM by Leo Leo

    Execute Javascript with BackButton

    Leo Leo

      Hi everyone,

       

      We are currently working on a Rhomobile Project and we are in front of a problem.

      Let me explain. In a page, we want to execute a JavaScript function by clicking on the back button. It works for the first time, showing an alert like "ok it works". But the second time we click on it, it doesn't open the JavaScript function at all. Worst, it redirects us on the previous page !

       

      We just want the JavaScript to execute without any redirections.

      Here is our code so far:

      def personalisee

            render :back => 'callback:' + url_for(:action => :callback_alert)

          end

         

          def callback_alert

            Rho::WebView.executeJavaScript("backButton();")

          end

      where personalisee is our controller and callback_alert, the function we want to call by clicking on the back button

       

      function backButton()

      {

        alert("works!");

      }

       

      We will really enjoy any solutions or even small hacks.

      Thank you for your answers!

       

      Leo