Reputation: 535
this is my way to hidden the #edit: There is a loading image in body, when the device is ready, it hides $edit and show loading image. when finish actions in getDetail, hidden #load and show #edit.
However, now the problem is, when opening the page, both load and edit are showed, and it works normally after getDetail function.
How should I modify the code?
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
$('#edit').hide();
getDetail();
}
</script>
js
function getDetail() {
$('#load').hide();
$('#edit').show();
}
html part
<div id='load'>
<img src="loading.gif"
style="margin-left:auto; margin-right:auto; ">
</div><!-- /load -->
<div id='edit'></div>
*Extra Question * Do I need to return false;
in last line of getDetail()? Because all my javascripts are put in a js file. getDetail() is the first function. after running this function, i found that other functions are not work, even a simple on click function to alert something, those functions can only work if put the script in inline style in body.
ps. fixed some copy and paste error
Upvotes: 0
Views: 132
Reputation: 16544
You have a syntax error
There are extra closing brackets inside the getDetail() method. Syntax errors will not only affect this part of the code, they will break the whole script.
Then you should initially hide the #edit
element using CSS
#edit {display: none;}
which renders the statement to hide this element useless. Just remove the part $('#edit').hide()
And: You shouldn't close the <script>
tag before the end of your Javascript code.
Upvotes: 1
Reputation: 2093
Just modify
<div id='edit'></div>
to
<div id='edit' style="display:none;"></div>
And also remove the line:
$('#edit').hide();
It does not have any effect as it is getting shown immediately after being hidden.
Upvotes: 1