I have a view in my rhomobile app where I want to hide and show certain div's, using jQuery and Javascript. The Javascript code is embedded in the view file, but is not getting executed. This piece of code for example doesn't do anything in my app:
<script type="text/javascript">
$(document).ready(function () {
alert("loaded submit.erb...");
showLoadingIndicator();});
</script>
I'm using the standard layout.erb which comes with a freshly generated app project. Any help is highly appreciated.
HTML output:
<script type="text/javascript">
$(document).ready(function () {
alert("loaded submit.erb...");
showLoadingIndicator();});
function showLoadingIndicator(){
setTimeout(function(){
$('#loadingPlaceholder').hide();
<% if @params["body"] == "SUCCESS" %>
successfull();
<% elsif @params["body"] == "FAILED" %>
<%= puts "### FAILED ###" %>
not_successfull();
<% else %>
wait();
<% end %>
},6000);
}
function successfull(){
$('#successfull').show();
}
function not_successfull(){
$('#not_successfull').show();
}
function wait(){
<%= puts "+++ body => +++" %>
<%= puts @params %>
<%= puts "++++++++++++++++++" %>
}</script>
<div data-role="page">
<div id="loadingPlaceholder" style="width: 100%; height: 250px; text-align: center; position: absolute; display: block">
<div>
Ihre Anfrage wird gesendet...
</div>
</div>
<div id="successfull" style="width: 100%; height: 250px; text-align: left; position: absolute; display: none">
Ihre Anfrage wurde gesendet.<br>
Wir setzen uns umgehend mit Ihnen in Verbindung.
</div>
<div id="not_successfull" style="width: 100%; height: 250px; text-align: left; position: absolute; display: none;">
Leider konnte Ihre Anfrage nicht versendet werden.<br><br>
Bitte versuchen Sie es später noch einmal.<br>
</div>
</div>