Rhomobile从Rho3.1迁移到Rho 4.0 Alert Msg。错误

时间:2014-03-21 11:53:33

标签: ruby rhomobile rhodes

我正在尝试将我的rho应用程序从3.1迁移到4.0。在3.1中,我已经使用Alert.show_popup :title => "Please Wait", :message => "Fetching Data..."定义了警报但是正如文档中所指定的那样,现在我将其更改为

dataPopProps = Hash.new
dataPopProps['message'] = "Fetching Data...";
dataPopProps['title'] = "Please Wait";
Rho::Notification.showPopup(dataPopProps)

但我仍然得到同样的错误。Error Shown on mobile 错误:未正确定义按钮列表。 DIalog将无法启动

任何帮助都会很棒。

2 个答案:

答案 0 :(得分:1)

试试这个,

 dataPopProps = Hash.new    
 dataPopProps['message'] = "Fetching Data...";
 dataPopProps['title'] = "Please Wait";    
 dataPopProps['buttons'] = ["Ok"]
 Rho::Notification.showPopup(dataPopProps)

答案 1 :(得分:1)

为了将来参考,官方文档通常是不正确的,因此使用Rhodes可能会令人沮丧。但是,the example listed here似乎是一个很好的解决方案。请注意,通知的示例是在Javascript中。

这是在Ruby中编写此内容的一种优雅方式:

dataPopProps = {
  'message' => 'Fetching Data...',
  'title'   => 'Please Wait',
  'buttons' => [{ :id => 'no', :title => 'no' }]
}

在Ruby中,分号是完全不必要的,您可以使用文字而不是Hash.new来清理代码。