mobile back button not working in phonegap project? - eclipse

When i click on a link this will redirect me to another page in my app.
But after that when i am clicking on the mobile's back button it is not redirect me to previous page.
Ca anyone have answer of this question.

Actually device's back button click is also an event in PhoneGap. You can define the beckbutton event as a function.
<html>
<head>
<title>Sample</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", backButtonClick, false);
}
function backButtonClick() {
//Do something here on backbutton click or go back to last page.
window.history.back()
}
</script>
</head>
<body>
</body>
</html>
Its a sample, now tweak your page as you wanted.
Always write the backbutton event on deviceready!

Related

I need an Alert box on site load then vanish after 10 seconds

I am about to start a work on a alert box or Modal, that will Pop-up when the sites loads and after 10 seconds it disappear.
I am looking for a html/css solution, if possible.
Can any body lend me an idea on how to achieve it?
Here's a working example based on what you need as a modal popup.
<html>
<head>
<title>Model popup box</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$('#modal').delay(10000).fadeOut();
});
</script>
</head>
<body>
<div id=modal > Hello, i am a modal popup </div>
</body>
</html>

PhoneGap not working on iOS 5 device

Hi i tried creating sample index.html with simple notification code from Docs Phonegap Notification .
I zipped the index file and uploaded it to build.phonegap.com with 2.9 version. The App is successfully installed on my iPad(iOS 5) but nothing happen when i click on Show Alert. I also tried adding phonegap 2.9.0 on my Sencha Touch 2 Application ,i build it as native and installed it on my device but the app hangs on app Loading Indicator.
Index.html code:
<!DOCTYPE html>
<html>
<head>
<title>Notification Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
// Empty
}
// alert dialog dismissed
function alertDismissed() {
// do something
}
// Show a custom alertDismissed
//
function showAlert() {
navigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}
</script>
</head>
<body>
<p>Show Alert</p>
</body>
</html>
Any help is greatly appreciated.
Update:
Got things working when i add config.xml on the zip file. And added phonegap.js script inside the body tag before uploading it to build.phonegap.
Thanks
Got things working when i add config.xml on the zip file. And added phonegap.js script inside the body tag.
Thanks

How to refresh tab panel in MVC?

I m new to MVC. I need to refresh tab panel after 10 seconds in MVC.
Can anybody help me in that?
Thanks
you can do that using JQuery or ajax the following is a sample example using Jquery
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
var refreshId = setInterval(function()
{
$('#responsecontainer').fadeOut("slow").load('your target page will be here').fadeIn("slow");
}, 100);
</script>
</head>
<body>
<div id="responsecontainer">
here you can place your Div,html or ASP.net control
</div>
</body>
</head>
</html>
The div or whatever you use for content should have an id and should be rendered as an action that returns a partial view. Then you can use JavaScript to set the timer, and jquery Ajax call to replace the content with what is returned by calling the URL you get by URL.Action.

iPhone/iPad HTML5 Canvas fillText problem

I'm having strange issues with text on a canvas when using an iPhone or iPad.
Either the text gets drawn properly (rarely), or it gets drawn upside down, or it doens't get drawn at all.
When the text does manage to get drawn, it is wiped when the iPhone/Pad is rotated.
I have the following code. It seems that I can only get the text to stay on the page at all if I use a setTimeout. It seems to be drawn over if I call fillText as soon as the document is loaded.
Anyone else experiencing this sort of problem?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="http://code.jquery.com/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
//draw_b();
setTimeout('draw_b()', 500); ;
});
function draw_b() {
var b_canvas = document.getElementById("cv");
var context = b_canvas.getContext("2d");
context.fillText("Belated hello world", 50, 50);
}
</script>
</head>
<body>
<canvas id="cv" width="300" height="225"></canvas>
</body>
</html>
I have the same problem ,
the earlier version(3.2) doesn't support HTML5 Canvas filltext,
You can use alternative API such stroketext to fix this issue: http://www.netzgesta.de/dev/text/#canvas_api

facebook PermissionDialog

<script
src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"
type="text/javascript"></script>
<script type="text/javascript">
FB.init('cef61789d5df166ac00c9fe13007c110', "xd_receiver.htm");
FB.Connect.showPermissionDialog("offline_access");
</script>
After a user login i am using the above code to get the Dialog box.
Why itsnt showing permission dialog??
I had this problem. Wrap the call to FB.Connect inside an "ensure init" like so:
FB.ensureInit(function() { FB.Connect.showPermissionDialog("offline_access"); });
That cleared things up for me.