rubyclickalertrhomobilerhodes

Alert ok button event in Ruby


I am creating a Rhodes cross platform application. Somewhere in my application I am displaying an Alert with a default OK button. This is my code :

Alert.show_popup "Payment successful. Your Transaction Number :  "+$payment["transactionid"].to_s
WebView.navigate ( url_for :controller => :Categories, :action => :index )

What actually happens is I am displaying Alert as well as navigating simultaneously. But what I want is to navigate only when I click that OK button on the Alert.


Solution

  • You should use a callback function, where you would perform the navigation. Try something like:

    Alert.show_popup(:message => "Payment successful. Your Transaction Number : "+$payment["transactionid"].to_s, 
                    :callback => :go_to_categories_cb)
    

    And in the same module define the callback method:

    def go_to_categories_cb
        WebView.navigate ( url_for :controller => :Categories, :action => :index )
    end