K
K
Kirill Sirenko2015-07-25 00:04:49
JavaScript
Kirill Sirenko, 2015-07-25 00:04:49

Why might jquery or javascript not work in a PhoneGap app?

A simple application was developed, the essence of which is to give a web page specified in advance with its contents through the phonegap platform, and in the absence of the Internet, write a warning about this and not display anything.

The strange thing is that the form validation (the simplest check of the field for fullness - it works in the browser, in the mobile browser = works, but in the application itself - no)

var emptyFields = $(":input.required").filter(function() {
      
      // $.trim to prevent whitespace-only values being counted as 'filled'
      return !$.trim(this.value).length;
    });
    
    // if there are one or more empty fields
    if(emptyFields.length) {
      
      // Тут код если поле не заполнено
    }
    else
    {
// Тут код, если поле заполнено
}


And many more ways:

if($.mobile.activePage.find('form#callform #code').val().length !=0) {...}
if($("#code").val().length !=0) {...}
if(document.getElementById('code').value !== "") {...}
if(code.length != 0) {...}
if($('#code').is(':empty')) {...}


Also - they work fine in browsers, but do not work in the application.

What is the reason and how can it be cured? Just don't say that writing a native app :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2015-07-25
@AMar4enko

Connect the chrome debugger to the device and debug.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question