user1223160
user1223160

Reputation:

Using jQuery with Other Libraries

My home page contains:

<script src="js/Config/jquery-1.4.3.min.js"></script>
<script src="js/Config/jquery.mobile-1.0a1.min.js"></script>

then, a button that leads me to another page test.html that contains:

<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function()
    {
        getCategories();
        getnameCategories();
    });
</script>  
</head>
<body >...

But jQuery(document).ready(function() is not working!! And if I made just ​​one call to a single library, either jquery.mobile-1.0a1.min.js or jquery-1.4.3.min.js on the home page, the code work well, but I loss the graphic effect of jquery!!!! What is the problem??

Upvotes: 0

Views: 370

Answers (3)

dali
dali

Reputation: 164

your jQuery(document).ready(function() won't fire coz when jquery mobile load external pages it looks for the first page of your document and it don't load the associate scripts specified in the head section.

what you have to do is to load all your java script in your first html page and also put you code in $("#test").live("pageshow",function(){} where test is the id of the first page located in test.html

it should look like this in your .js:

$("#test").live("pageshow",function(){
    jQuery.noConflict();
    getCategories();
    getnameCategories();

}

and like this in test.html:

    <!DOCTYPE html>
<html >
<head>
</head>
<body>
  <div id="test" data-role="page"> 

 </div>

</body>
</html>

Upvotes: 0

Ryan
Ryan

Reputation: 28177

Your new page test.html should also contain a reference to the jquery-mobile library.

Also, when using jQuery Mobile, use pageInit rather than jQuery's ready(...) function. See the documentation here.

Upvotes: 1

Manikandan Sethuraju
Manikandan Sethuraju

Reputation: 2893

I think, you need to check the dependent Jquery libraries of "jquery.mobile-1.0a1.min.js" and need to call that dependent jquery libraries links to your page. i mean you should call the libraries like,

<script src="js/Config/jquery.mobile.themeswitcher.js"></script>
<script src="js/Config/jqm-docs.js"></script>

Upvotes: 0

Related Questions