I am new to phonegap. I am using phonegap with IOS. the problem i am facing is, JS function window.open('URL') is not working. it gives nothing. can anyone help me what is actually going on?
Thanks
To show the confirmation box you need to do some thing like this
//process the confirmation dialog result
function onConfirm(button) {
alert('You selected button ' + button);
}
// Show a custom confirmation dialog
//
function showConfirm() {
navigator.notification.confirm(
'You are the winner!', // message
onConfirm, // callback to invoke with index of button pressed
'Game Over', // title
'Restart,Exit' // buttonLabels
);
}
Just invoke the showConfirm() on click of a button...
try this:window.location ='http://www.google.com';
window.location.href ='http://www.google.com';
I used simple page with pop transition because jquery dialog is also works as a page but it effects your css, thats why i use a simple page with pop transition. and it appends in the current DOM due to which i have all of access to previous page form. just like openr in case of Window.open()
problem solved
Related
I'm writing protractor tests for an existing app.
I have a button called 'Decline' in a modal window, and I'm trying to click it using:
element(by.buttonText('Decline')).click();
But I receive the below error:
UnknownError: unknown error: Element is not clickable at point (,). Other element would receive the click:
May be because I have another button called 'Decline' outside the modal window?
How do I click on the modal window's Decline button ?
Found that this is the js code that displays this Decline button.
.....
var content = {
title: 'Decline',
htmlBody: '<p>...</p> ',
okButton: 'Decline',
onOk: function() {
.....
As there are two buttons with button text Decline, How do we identity the one in modal?
One way to approach that would be to improve your locator to work in the scope of the modal content. But, since you have not provided an HTML representation of the modal I cannot provide you with a specific answer. Here are the samples that you can improve to fit your use case:
element(by.css(".modalContent button[ng-click*=ok]")).click();
element(by.css(".modalContent")).element(by.buttonText("Decline")).click();
Another approach could be to find all buttons with a specific text and filter the visible one:
element.all(by.buttonText("Decline")).filter(function (button) {
return button.isDisplayed().then(function (isDisplayed) {
return isDisplayed;
});
}).first().click();
My Colleague recommended this and it worked:
Clicking on First Decline button opens up a modal,
Sleep for some time,
Now click on the second Decline button.
element(by.buttonText('Decline')).click();
browser.sleep(2000);
element(by.cssContainingText('.btn', 'Decline')).click();
Thanks for all your help :)
Write the code
which needs to display under modal window,
inside form tag.
And serialize that form with the existing form.
Just search the button by its text and use the function click. So for you it should look like that:
element(by.buttonText('Cancel')).click();
try the below code,
var DeclineBtn = element(by.buttonText('Decline'));
browser.executeScript("arguments[0].click()",DeclineBtn.getWebElement())
I have a modal that is displayed only once (like a dialog box) after user logged-in firstly. And also I've got a function in that modal file that is supposed to run if modal is displayed.
Here is function:
$('#some_element').(function someFunc() {
console.log("gUM is used now");
//some stuff to do
});
I tried on('click') and it works fine. But I don't need it.
Also, I tried on('load'), but it works before modal is displayed.
Any help will be appreciated. Thanks in advance.
Hello i think you can use events. for example for jquery dialog there is many events and function to know if dialod is open http://api.jqueryui.com/dialog/#method-isOpen and some events like open or beforeClose or you can use jquery to detect if the element is visible $("#SomeElement").is(":visible")
Not an ideal solution but you could start a timer in on load, and have it run a function every half second to check if the modal is visible:
var checkModalTimer;
$(document).ready(function() {
checkModalTimer = setInterval(function() {
if ($('modal').is(':visible')) {
// do your function
clearInterval(checkModalTimer);
}
}, 500);
});
I'm tasked with replacing a Javascript prompt call with a custom function that uses a fancy Javascript-activated modal dialog.
The function is called once and expects a string back, with the input from the user. I cannot control how the function is called (it's an external library.)
Making the modal and getting input is easy. How do I return the input to the caller of my custom prompt function after the user clicks the Submit/OK button?
jQuery is fine.
The browser implementation for prompt() is implemented in a way that is not possible to replicate with user-level Javascript running on the page. You have to use callback functions. And if it were possible, there would already be a ready made solution that you should use.
What I am saying is that the user of your code cannot have this:
var result = customPrompt(...);
Rather they must have something in the lines of this:
customPrompt({
...
ok: function() {
//when user clicked ok
},
cancel: function() {
//when user clicked cancel
}
});
//Code continues to run here and doesn't wait for the user to click ok or cancel
This is how you can get the user's input into the same function as your modal launcher so you can handle it.
<input type="text" id="user-input" />
OK
function handlePrompt(launchModal){
if(launchModal){
// Code to Launch Modal
}else{
var userInput = $("#user-input").val();
// Do what you want with the input.
}
}
In checkout page of my magento store, I need to clear some inputs when an alert box is showed and user press OK. Is possible to do that?
I have no control over the javascript alert. So I think in a script that detect an alert with a specific message and clear inputs when button of that alert is clicked.
UPDATE
Fixed!
file: opcheckout.js
line: 888
I add location.reload(); because document.location.reload(true); not work on IE. Thanks everybody!
Probably try overriding default alert and write a custom function like below,
var c_alert = alert;
window.alert = function (str) { //override default alert
c_alert(str + ' my message');
location.reload();
//or write code to clear input fields here
}
//below seems to be triggered from somewhere where you don't have control.
alert('test');
Javascript
if(confirm('your confirmation text')){
document.location.reload(true);
}
Make it refresh after the alert. The javascript code shouldn't execute before the alert is gone
I'm new to html& jquery. I'm having a dialog and while trying to close it, I need to ask a confirmation message, which should be displayed on top of the existing dialog. I tried using jconfirmation, but it comes up after closing the existing dialog. But I need the confirmation to come on top of the existing dialog. How can I do it?
$("#ref").load('myTest.html').dialog({
create:function(e,u) {
// ETC
},
close:function(e,u){
//ADD CODE TO SHOW CONFIRMATION ON TOP
}
});
Hi Dialog will fire close callback after it is closed. Try using beforeClose event. You should be able to use the same call back that you are using for close with it
$("#ref").load('myTest.html').dialog({
create:function(e,u) {
// ETC
},
beforeClose:function(e,u){
//ADD CODE TO SHOW CONFIRMATION ON TOP
}
});
http://docs.jquery.com/UI/API/1.8/Dialog#event-beforeClose