1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Nitish
  • 13,845
  • 28
  • 135
  • 263
  • Nitish, for somebody with quite a bit of SO reputation, that's a rather bad question. What have you tried already, where did you have problems etc? – Michael Kohl Nov 24 '11 at 10:05
  • @MichaelKohl : :) Actually I am new to Ruby development. Basically I am into IPhone development. I was just not able to figure out how to capture OK button event for Alert. Yes my question could had been better. – Nitish Nov 24 '11 at 10:11
  • Well, you still didn't show us any code you already tried and where exactly your problem lies. But this sounds like it's more of JS problem than a Ruby one. – Michael Kohl Nov 24 '11 at 10:14
  • You need to provide many more details. What is the context? A web application? A GUI application? – Carl Zulauf Nov 24 '11 at 10:14
  • @MichaelKohl & Carl : I have edited my question. Please see – Nitish Nov 24 '11 at 10:21
  • I'm not familiar with Rhodes, but added the appropriate tags so people in the know are able to find your question. – Michael Kohl Nov 24 '11 at 10:41
  • Got the answer [here](http://docs.rhomobile.com/rhodes/device-caps#alerts). – Nitish Nov 24 '11 at 12:06

1 Answers1

1

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
Pablo
  • 2,834
  • 5
  • 25
  • 45