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??
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 :
function ajaxBridge(method,funcName,onSuccess)
{
$.ajax({
type: method,
url: funcName,
async: true,
error: function(xhr){alert("Custom Uncaught AjaxBridge Error 11 :" + "<br/>" + xhr.responseText);},
success: onSuccess
});
}
on you .erb file or view you can have :
<input type="button" value="Login" onclick="doValidation()"/>
create a script on the same page to call our ajax method, i am also sending login information to the method :
<script type="text/javascript">
function doValidation(){
var login = $('input#login').val();
var password = $('input#password').val();
ajaxBridge("POST","<%= url_for :controller => :Survey, :action => :do_login %>"+"?login="+login +"&password="+password,function(){});
}
</script>
Note: Do include
<script type="text/javascript" src="/public/js/AjaxConnector.js"></script>
to specify the source for the ajax.
hope i helped.
Finally i resolved it by my self.
Instead of writing this code 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>
replace it with this one
<div data-role="content">
<br /><br />
<div data-role="fieldcontain">
Email Address : <input type="text" name="Email" /><br />
</div>
<form method="POST" action="<%= url_for(:controller => :Settings, :action =>:show_VibLoc) %>">
<input type="submit" value="Submit" />
</form>
Thanks for looking at this question :)