Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Mobile application with Require JS and Sammy
    primarykey
    data
    text
    <p>I am pretty new to web apps in Mobile device. I am evaluating couple of libraries that I will be using for my upcoming project and I have chosen jQuery Mobile, Sammy and Require JS. I was trying to integrate them in a sample app to get familiarize and i am completely thrown off.</p> <p>I am trying to do a basic stuff basically loading the modules using requirejs and redirecting the user to a template. To my surprise i see that template is getting loaded to DOM but the jQuery styling is never applied i have no idea what is the reason. I am trying to append the template directly to the body of my start page which is index.html. </p> <p>I tried to append it in div but jQuery mobile wraps the div into a page and nesting page is not available in jQuery mobile. Any help will be greatly appreciated. I am also pasting some code to give high level idea what I am trying to achieve.</p> <p>index.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;New Project&lt;/title&gt; &lt;link rel="stylesheet" href="styles/jquery.mobile-1.3.1.css"/&gt; &lt;link rel="stylesheet" href="styles/style.css" /&gt; &lt;script type="text/javascript" src="js/require/require.js" data-main="js/common"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>AMD module Common JS</p> <pre><code>require.config({ baseUrl: "js/", paths: { jquery: 'lib/jquery/jquery-1.10.1', 'jquery.mobile': 'lib/jquery/jquery.mobile-1.3.1', 'jquery.mobile.config': 'lib/jquery/jquery.mobile.config', underscore: "lib/underscore/underscore", ko: "lib/knockout/knockout.min", postal: "lib/postal/postal", amplify: "lib/amplify/amplify", text: "require/text", sammy: "lib/sammy/sammy", 'sammy.template':"lib/sammy/plugin/sammy.template", router : "Router" }, priority: ['jquery', 'jquery.mobile','jquery.mobile.config','sammy','sammy.template'], shim: { ko: { exports: "ko" }, underscore: { exports: "_" }, amplify: { exports: "amplify" }, 'jquery.mobile': ['jquery','jquery.mobile.config'], 'sammy': { deps: ['jquery','jquery.mobile'], exports: 'Sammy' } , 'sammy.template': { deps: ['sammy']}, 'router': { deps: ['sammy.template']} }, waitSeconds: 60 }); require(["jquery",'router',"jquery.mobile"],function($,Router,){ console.log('1'); //GlobalContext.initialize(); }) ; </code></pre> <p>My router.js</p> <pre><code> define(['jquery','sammy','sammy.template'],function($,Sammy){ return Sammy( function() { this.use('Template'); this.element_selector = 'body'; this.get('#/', function(context) { context.app.swap(''); alert(context.$element()); context.render('view/hello.template') .appendTo(context.$element()); }) .then(function(){ $('#main').trigger("create") }); this.get('#/item', function(context) { context.app.swap(''); context.render('view/page2.template') .appendTo(context.$element()); }); }).run('#/'); }); </code></pre> <p>My template that I am trying load saved as hello.template</p> <pre><code>&lt;script type="text/javascript"&gt; require(["jquery","jquery.mobile"],function($){ console.log('2'); $('#myText').val('AAAA'); }); &lt;/script&gt; &lt;div data-role="page"&gt; &lt;div data-role="header" data-theme="b" data-position="fixed"&gt; &lt;h1&gt;Main Menu&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;input type = "text" id = "myText" value = "text here" /&gt; &lt;ul data-role="listview" data-inset="true" data-filter="true"&gt; &lt;li&gt;&lt;a href="#"&gt;Acura&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Audi&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;BMW&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Cadillac&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Ferrari&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div data-role="footer"&gt; &lt;h4&gt;Page Footer&lt;/h4&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Thanks in advance for any input</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload