Submit button is not working in phonegap - jquery-mobile

I wrote the code for login page,when i am running on desktop using phonegap desktop it working perfectly,but while i build that using phonegap build and when i tried to open in my phone the submit button is not working.Here is my code:
<script>
$(document).ready(function(){
});
function btnclick(){
debugger;
$.ajax({
type:"GET",
url: url/"+$('#useName').val()+"/"+$('#Password').val(),
contentType: "application/javascript",
jsonpCallback: "Login",
dataType: "jsonp", //Expected data format from server
});
}
function Login(data)
{
if(data==true)
{
window.location.assign("home.html");
}
else{
$('#error').show();
}
}
</script>
</html>
And for giving input:
<form>
<input id="useName" type="text" placeholder="E-mail address" />
<input id="Password" type="password" placeholder="Password" />
<input type="submit" value="submit" id="btnclick" onclick="btnclick()" />
</form>

The only thing I can think of that is causing you troubles is the whitelist configuration needed for navigating external sources.
you should add on your config.xml something like:
<access origin = "*" />
<allow-navigation href="http://*/*" />
you can modify them to fit your needs but do try it out fist with a global access to verify that this is your problem.
Also add the cordova whitelist plugin
<gap:plugin name="cordova-plugin-whitelist" source="npm" version="1.0.0"/>

Related

Issues with using d2l remote plugins (insert stuff cim) example not working

I am new to Brightspace and been fiddling with the remote plugins sample (logo). I can load the sample logo project, but cannot get it to insert into the page. I have uploaded the file but get a 404 error on submit. Can someone `
$( document ).ready(function() {
$('#submitFormButton').click( function() {
$.ajax({
url: "/getisfdetails",
data: {
image: $("input[name='image']:checked").val()
},
success: function(response){
$("input[name='lti_message_type']").val(response.lti_message_type);
$("input[name='lti_version']").val(response.lti_version);
$("input[name='content_items']").val(response.content_items);
$("input[name='oauth_version']").val(response.oauth_version);
$("input[name='oauth_nonce']").val(response.oauth_nonce);
$("input[name='oauth_timestamp']").val(response.oauth_timestamp);
$("input[name='oauth_consumer_key']").val(response.oauth_consumer_key);
$("input[name='oauth_callback']").val(response.oauth_callback);
$("input[name='oauth_signature_method']").val(response.oauth_signature_method);
$("input[name='oauth_signature']").val(response.oauth_signature);
$("#isfForm").prop('action', response.lti_return_url);
$("#isfForm").submit();
}
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<body>
<h3>Select an logo:</h3>
<input type="radio" name="image" value="brightspace-logo.png"> <img src="../content/isf/brightspace-logo.png" alt="Brightspace Logo"><br />
<input type="radio" name="image" value="d2l-logo.png"> <img src="../content/isf/d2l-logo.png" alt="D2L Logo"><br />
<div hidden>
<form id="isfForm" method="POST">
<input type="hidden" name="lti_message_type" />
<input type="hidden" name="lti_version" />
<input type="hidden" name="content_items" />
<input type="hidden" name="oauth_version" />
<input type="hidden" name="oauth_nonce" />
<input type="hidden" name="oauth_timestamp" />
<input type="hidden" name="oauth_consumer_key" />
<input type="hidden" name="oauth_callback" />
<input type="hidden" name="oauth_signature_method" />
<input type="hidden" name="oauth_signature" />
</form>
</div>
<br />
<button id="submitFormButton">Submit</button>
</body>
` how do you set this cookie in the javascript? I believe a cookie needs to be set??? and I do not see how to set it? or maybe I am missing something else that is not noted in the documentation.
I would highly recommend you consider using LTI Advantage/1.3 instead of Remote Plugins. LTI provides a standards-based integration approach & a better developer experience.
https://community.brightspace.com/s/article/LTI-Integration-Guide
If you are working with a partner of D2L please get in touch with the partner team and technical assistance is available. Your information here is appreciated but we are glad to examine the full context and use case as these errors are not hugely uncommon during dev. Otherwise, I echo Paul's suggestion, but I understand if it is not immediately possible.
partners#d2l.com or talk with your team that knows D2L!
Depending on which browser you are in you might be seeing the recent effects of the third-party cookie blocking that the browsers are adopting. Because LTIs (both 1.1 and 1.3/Advantage) typically launch into iframe any access to those cookies are regarded as third party. This effectively means two things
You need to be aware of the cookie access routines where a user action must be taken to request access to the browser storage API using document.requestStorageAccess()
You need to be marking your cookies appropriately with the new SameSite cookie directives
Without these the browser will mark your cookie request as a 'Tracking cookie' and refuse to serve it along with the request or make it accessible via javascript.
An alternative is also to detect that the LTI launch is happening inside the an iframe and to bust that iframe out to a new window, or alternatively configure the launch inside Brightspace to not use a iframe at all.

Stripe in wkwebview open a browser page loading script

we're moving with our APP to new new wkweview due to the apple requirements.
One of APPs, is using StripeJS sdk in order to allow payment in app. Problem occurs when APP is bootstraping and the stripe sdk is include with the following code:
// Payment service is not initialized yet
$.ajax({
type: "GET",
cache: true,
url: "https://js.stripe.com/v3/",
dataType: "script",
error: function(XMLHttpRequest, textStatus, errorThrown) {
Logger.error("An error ocurred during SDK download");
def.reject();
},
success: function() {
Logger.debug("Stipe JDK downloaded correctly");
initialized = true;
def.resolve();
}
});
We already tried to use '' head tag in the index.html or creating dynamically one script TAG and appenging it to the body: but no one fix the problem.
Script Inclusion Tests
[Angular $http method]
$http({
method: "GET",
url: "https://js.stripe.com/v3/"
}).then(
function(res) {
angular.element("body").append("<script>" + res.data + "</script>");
}, function(err) {
def.reject();
});
[index.html]
<html>
<head>
<script type="text/javascript" src="https://js.stripe.com/v3/"></script>
...
Problem
A browser page is opened and APP is left in the background; being more specific, the "METRICS_CONTROLLER" case is catch in switch at row 767 ( see library at url < https://js.stripe.com/v3/ > ).
Have anyone an idea why including that script the browser page is opened ?
just to answer my question we found the problem.
The problem was about permission to navigate url not allowed by the cordova configuration ( file 'config.xml' ).
More specifically, we need to add the following row in our config. file
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
So finally, our CORS permission definition is:
<access origin="*" />
<allow-intent href="sms:*" />
<allow-intent href="tel:*" />
<allow-intent href="geo:*" />
<allow-intent href="mailto:*" />
<allow-intent href="file://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
'*' is due to the fact that the APP can trigger outside resource, so we cannot known which url will be opened by user in APP.
Hope this help #saperlipopette
Simon

How to set JQuery Mobile datebox popup at the center of window?

I'm using JQM datebox as following now:
<input name="startTime" id="startTime" type="text" data-role="datebox" data-options={"mode": "datebox"}>
But the datebox doesn't pop up at the center of window.
How can I to do it?
You can force the Position of the PopUp: http://dev.jtsage.com/jQM-DateBox/api/popupPosition/
Example 1 (http://jsfiddle.net/Twisty/6swq0t0k/1/):
<input name="startTime" id="startTime" type="text" data-role="datebox" data-options='{ "mode": "datebox", "popupPosition": "window"}' />
Example 2:
<input name="startTime" id="startTime" type="text" />
<script>
$("#startTime").datebox({
mode: "datebox",
popupPosition: "window"
});
</script>
This will force it to center in browser window. You can also center over another element by it's ID if you want.

How to destroy Jquery UI spinner on blur

Hello guys i had textboxes and i want them to be a spinner when focused and to be the textbox when blur
this is my code
$(".spinner").focus(function () {
$(this).spinner();
});
$(".spinner").blur(function () {
$(this).spinner("destroy");
});
demo
http://jsfiddle.net/ygyogba0/
but im getting an error of "Cannot read property 'replaceWith' of undefined"
can anyone help me with this?
thanks in advance
This is working for me in chrome and IE11. It seems that the spinner widget was not setting focus after it's create. Using "On" is a great practice esp if you start doing partial postbacks. However, in firefox it was not setting the focus even with the extra call. This is an issue discussed at length in forums. If you need FF you will have to deal with that.
However, The FF issue is only an issue if the user never clicks in the spinner. I am not sure this solution is ready for prod.
$("body").on("focus", ".spinner", function () {
$(this).spinner({
create: function (event, ui) {
$(this).focus();
// Trying (and failing) to deal with FF
/*setTimeout(function () {
$(this).focus()
}, 10); */
}
});
});
$("body").on("blur", ".spinner", function () {
$(this).spinner("destroy");
});
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<input type="text" class="spinner" /><br>
<input type="text" class="spinner" /><br>
<input type="text" class="spinner" /><br>
<input type="text" class="spinner" /><br>

Phonegap Facebook Connection can not find JavaScript

I know there are a few articles discussing this issue, I followed them all with no luck.
I am getting the ever issue - "Facebook variable does not exist. check that you have included the Facebook JS SDK file"
My bundle name in Xcode is org.apache.cordova.Game
So if I understood correctly in my config file I wrote:
<gap:plugin name="org.apache.cordova.Game.plugins.FacebookConnectPlugin">
<param name="APP_ID" value="123123" />
<param name="APP_NAME" value="Game" />
</gap:plugin>
I am trying to launch the sample index.html and the cdv-plugin-fb-connect.js and facebook-js-sdk.js are both in www folder (copied the js using finder and no action from Xcode)
index.html copied to www in finder as well and the source is :
<body>
<button onclick="login()">Login</button>
<button onclick="me()">Me</button>
<!--<button onclick="getSession()">Get session</button>-->
<button onclick="getLoginStatus()">Get login</button>
<button onclick="logout()">Logout</button>
<button onclick="facebookWallPost()">facebookWallPost</button>
<button onclick="publishStoryFriend()">friendstory</button>
<div id="data">loading ...</div>
<!--<script src="http://localhost:8080/target/target-script-min.js#anonymous"></script>-->
<div id="fb-root"></div>
<!-- cordova -->
<script src="cordova.js"></script>
<!-- cordova facebook plugin -->
<script src="cdv-plugin-fb-connect.js"></script>
<!-- facebook js sdk -->
<script src="facebook_js_sdk.js"></script>
<script>
.........
First of all from cordova 3 the one should add the the config file the plugin as feature and not as plugin
<feature name="org.apache.cordova.facebook.Connect">
<param name="ios-package" value="FacebookConnectPlugin" />
</feature>
Second of all in the html it should be on device ready and not as documented in the web dev API by FB:
document.addEventListener('deviceready', function() {
try {
FB.init({ appId: "12345", nativeInterface: CDV.FB, useCachedDialogs: false });
FB.Event.subscribe('auth.authResponseChange', function(response) {
getProfile();
});
} catch (e) {
alert(e);
}
}, false);

Resources