在 rhoMobile 中单击按钮时显示视图
我在 rhomobile 中创建了一个简单的项目。 我的主屏幕显示一个文本框和一个按钮。
这是 index.erb
中的代码
<div data-role="content">
<br /><br />
Email Address : <input type="text" name="Email" /><br />
<form method="POST" action="<%= url_for(:action =>:show_VibLoc) %>">
<input type="submit" value="Submit" />
</form>
现在我在应用程序文件夹下的设置文件夹中创建了一个新文件VibLoc.erb
。
在 VibLoc.erb
中,我仅显示两个按钮。
在设置文件夹下的 controller.rb
文件中,我创建了一个函数 show_VibLoc
,此函数呈现 VibLoc.erb
文件
,这里是代码:
def show_VibLoc
render :action => :VibLoc
end
代码编译成功,但是当我单击该按钮时,我看不到我的 VibLoc
视图。
我在这里做错了什么?
I have created a simple project in rhomobile.
My home screen shows a text box and a button.
here is the code for that in index.erb
<div data-role="content">
<br /><br />
Email Address : <input type="text" name="Email" /><br />
<form method="POST" action="<%= url_for(:action =>:show_VibLoc) %>">
<input type="submit" value="Submit" />
</form>
Now I have created a new file VibLoc.erb
in settings folder which is under app folder.
in VibLoc.erb
i am showing just two buttons.
In the controller.rb
file under settings folder i have created a function show_VibLoc
in This function it renders the VibLoc.erb
file
here is the code:
def show_VibLoc
render :action => :VibLoc
end
The code compiles successfully but when i click on that button i cant see my VibLoc
view.
what i am doing wrong here??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后我自己解决了。
不要在
index.erb
中编写此代码,而是将其替换为此代码
感谢您查看此问题:)
Finally i resolved it by my self.
Instead of writing this code in
index.erb
replace it with this one
Thanks for looking at this question :)
曾经遇到过同样的问题,我发现的方法是:
在项目的 public/js 文件夹中创建一个 .js 文件,并使用从控制器调用方法的函数:
在您的 .erb 文件或视图上您可以拥有:
在同一页面上创建一个脚本来调用我们的 ajax 方法,我还将登录信息发送到该方法:
注意:请包含
指定ajax的来源。
希望我有所帮助。
Had faced the same issue once, the approach i found out was:
to create a .js file in the public/js folder in the project with a function to call a method from the controller :
on you .erb file or view you can have :
create a script on the same page to call our ajax method, i am also sending login information to the method :
Note: Do include
<script type="text/javascript" src="/public/js/AjaxConnector.js"></script>
to specify the source for the ajax.
hope i helped.