Using Jquery mobile


(Steve Warby) #1

I am just playing around with jquery & query mobile…

I have added query.js and test to see if it loads
All okay.
I then test with $("#text1").toggle(2000);
And it works.

I now need to add Jquery mobile (so my lists are a mobile list)

I add the query mobile list js & css files and test as follows:

if (window.jQuery) {  
// jQuery is loaded  
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
if ( $.mobile ) {
alert ('jq mobile loaded');
} else {
alert ('jq mobile not loaded');
} 

Both alerts show they have loaded.

But I get this error in the console:

3361Unexpected CSS token: : jquery.mobile-1.4.5.css:3361Unexpected CSS token: :
I have tried loading the 3 files in different orders.
Any ideas what I am doing wrong here.

Cheers

Steve Warby


(Mark Hunte) #2

It would be easier for us to help if you post the project.


(Steve Warby) #3

jqueryTest.hype.zip (257.6 KB)


(Mark Hunte) #4

I will have a look at that. ta. But I was just looking a round and others seem to be getting this css error.
It may be one you can ignore…


(Steve Warby) #5

Sorry I didn’t mention the text and button don’t show.

i.e. the whole page fails to show.

I also turned off Protect from external styles


#6

“When the user clicks a link in a jQuery Mobile-driven site, the default behavior of the navigation system is to use that link’s href to formulate an AJAX request (instead of allowing the browser’s default link behavior of requesting that href with full page load)”

You may find that jQuery mobile is using an AJAX request thus ignoring the head info ultimately not calling the CSS. Could be the problem, or not.

More Info: http://demos.jquerymobile.com/1.3.2/faq/scripts-and-styles-not-loading.html


(Mark Hunte) #7

I think I tried it last night using a webserver and I got the same issue. If I load one of their demos fully into a widget It works.

I have had similar issues with jquery plugins before. The last time was a combination of making sure that the correct .js and css load in the correct order and not using the default built css and js but using the plugins builder to build a complete set.

Although I did try some of this last night I did not have enough time to dig deep into it.

One tip though is read the documentation on which .css and .js should be loaded first. This is important when using these type of plugins as they are normally linked and need to refer to one and other. If the wrong one is loaded first then it may try and speak to one that is not loaded yet.

In Hype I would put the plugins into the resources.
Then go to the head file and select and copy the links Hype has put in there.
Go back to the resources and select each plugin and uncheck include in head.
Go back to Head Paste the list back manually. and arrange them in the right order.


(Steve Warby) #8

HI Guys back playing around with jQuery mobile again.

I am following this : https://www.w3schools.com/jquerymobile/jquerymobile_get_started.asp

If I add the the necessary code into the header and use:

	if (window.jQuery) {  
// jQuery is loaded  
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
if ( $.mobile ) {
alert ('jq mobile loaded');
} else {
alert ('jq mobile not loaded');
}

I get that they are installed but the normal list (on the right) doesn’t get the jQuery mobile effect if I add all the script into the list ( on the left ) it shows.

I presume there but be a way to tell the list to use jQuery mobile.

Any ideas ?

Cheers

Steve Warby

jqueryMobileTest1.hype.zip (34.5 KB)