I just started with Backbone.js, I've read the documentation and also the Backbone Fundamentals book before doing anything. I want to create a PhoneGap application with the help of Backbone.js and I'm a little bit lost on where to place some logic in Backbone.js or how integrate jQuery Mobile.
I need jQuery Mobile because I want to build an app with this exact structure, 2 panels that you can open with a swipe movement.
To integrate jQuery Mobile, the only thing that I've to do to BBB is to add a new Shim (and libs) in the config file? Is that the correct workflow? Or should I touch something in vendor/?
Once I have the jQuery Mobile integrated to Backbone Boilerplate, I want to just reproduce the demo. I know how I will place this code in a old fashioned website, how I would place my files, etc. But when it comes to Backbone... I'm totally lost. Where is the place to put the JavaScript code that will start the functionality of the panels?
Thanks in advance!
Usually, using jQueryMobile with Backbone gives headaches. Luckily I found a solution that simplifies the problem. It's a library called Jackbone. The author explained it better than I could do:
Summary
Jackbone is a utility library that aims to structure the development
of rich HTML5 applications using JQuery Mobile, by extending the
Backbone framework. It heavily relies on Backbone, offering
specialized classes for your views and router. Additionaly, it defines
a controller interface, provide a view manager that handles life and
death of the Views and Controllers of your application.
https://github.com/Fovea/jackbone
Related
I am developing a hybrid mobile app using jQuery Mobile and AngularJS.
I decided to use a mix of the two for the following:
jQuery Mobile
good UI features
not too heavyweight (compared to Sencha Touch, for example)
AngularJS
good performance and resource management (caching, asynchronous requests)
personal experience
I have little to no experience with jQuery Mobile and, as I was learning, I noticed a potential conflict between the page navigation models of the two.
Should I use only one ?
If yes, which one is better suited for my needs ?
Are there any gotchas with this setup ?
Many thanks.
You can't compare them to each other.
Angular.js (like Backbone, Ember eg.) are MV* Frameworks (for SPA) which used to render html templates/views directly in the client instead of server. So you have a lot of application logic now in your frontend and this Frameworks are made to make your life better, coding this.
jQuery Mobile on the other side is a pure widget/plugin library. The AJAX navigation plugin load pages (something static, like html) into the DOM via AJAX. So you have to pre-render this pages on the server somehow.
If you started to build a SPA with Angular it doesn't make sense to use jQuery Mobile's AJAX navigation at all. (If it's a native mobile app you have no server anyway.)
Sure, you won't get far without an UI component library so use one of your choice (eg. jQM) but work with Angular's directives to init the plugins/widgets correctly on your DOM elements since a $(document).ready(...) or a $(document).on( "pageload", ... ) doesn't know anything about your Angular views.
Take a look at following projects:
http://angular-ui.github.io
https://github.com/angular-widgets/angular-jqm
This has been already addressed in HERE
Basically the article states that trying to intercept the navigation from angular can be painful, so leave all the routing jqm
I have a site that's done using ASP.NET MVC and jQuery. Is it possible to modify my existing project without too much of rework so that it can be used in phonegap to create iphone/android apps?
Here's an approach: move your logic to an MVC WebAPI (or other REST/webservice) project, then convert the MVC site into a simple html/javascript/css/image site (Mobile site). Then refactor your Mobile site to use Ajax/JS to query the WebAPI/Rest services you created. Once you've separated your code this way, you can then package the Mobile site with Phonegap. I'm not sure how much work that will be for you or your project. If you're using a lot of Html Helpers or Razor markup in your views it may be too involved.
The core point of my suggestion here is to separate your mobile UI layer and the backend processing layer so you can only package the Html5/UI/Javascript layer with Phonegap and leave the backend processing on your web server. I don't think I need to explain this, but obviously the app packaged with Phonegap is not going to have the MVC/.Net framework available on the mobile device to render views or execute controllers, etc. By migrating your UI to be simple Html5 and Javascript you can use Ajax/Jquery/Javascript calls against your backend, which you will probably want to host in ASP.Net MVC WebAPI.
Edit: Guess there was some confusion about my suggestion. I'm not saying this is the only way to do go, but this is what I'm familiar with as it's how our team builds our desktop/web + mobile + phonegap + mvc4 + webapi + kendoui application. This pattern works well for us so maybe it'll work for you too, or at least give you some ideas on how to structure your solution. Good luck!
I'm not sure but you need a server to compile the ASP.NET right? so I don't think that will work for you. I think you need to work with AJAX to do your ASP.NET work and separate your ASP.NET code and your HTML-jQuery because Phonegap wants a index.html file. You can store your ASP.NET files at a server tough
The answer to your question really depends on the type of site you are trying to convert. Are you just trying to put a native framework around HTML and get your app into an app store?
If it is is mostly or entirely informational in nature and you have simply used MVC to build brochure-ware type pages then it should be fairly easy to move. This assumes that there is little to no logic other than page to page navigation.
If your site instead pushes a lot of data around that relies on a back-end server you will need to re-architect it to store data locally or pre-fetch it via a manifest. Next you will need to implement a strategy that allows you to push your local data back to the server.
Does you app need to run in a disconnected state?
Phonegap is one of the options if you want to target multiple mobile platforms & may be most widely used. Since you are using jQuery, jQueryMobile will be a least learning-curve path to use. Effort is mostly on the front-end UI and will depend on how many screens you want to design to provide a sub-set or the full set of functionality you already have on the web UI. Most likely you will have to redesign your screens using the jquery-mobile UI widgets documented here. It is also a good way to show it to your customer the initial screen design with navigation.
jquery mobile is great for learning and designing , but it's slow in the web browser control that phone gap runs in .
you'll need a more lightweight framework for this .
you can use an inappbrowser control to show your site in case it's responsive , but you wont have the device camera and contacts and so ...
take a look at : http://docs.phonegap.com/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser
I've written several web-based applications using Backbone in the past, but now I'm starting a new mobile application with Backbone.js and jQuery Mobile. I'm looking at using Marionette or Chaplin to help provide better structure, view management and memory management. Eventually this will be wrapped up using PhoneGap to be deployed an an enterprise app.
However, I cannot seem to find anything that would indicate either of these work well (or don't work) with jQuery Mobile. To get the most benefits from them, I know I'll have to disable jQuery Mobile's, which is fine. I've also seen some questions with issues about require.js and JQM not working well together either. So does anyone know if it's easy to use either of these Backbone frameworks to develop mobile site in a way that will play nicely with JQM? Or have another Backbone based framework that is designed specifically for use with JQM?
The best Backbone + JQM tutorial that I know of is http://coenraets.org/blog/2012/03/using-backbone-js-with-jquery-mobile/
Marionette should work fine - though it will be rather slow at the moment. I've run Marionette based web apps on my phone's browser and it runs... but I am also aware that it ran slowly. I'm working on performance improvements for the next release (v0.9) but that may be another week or two away, depending on how much time I have before my next contract starts.
I've read the Sencha Touch docs. I feel its MVC model is very attractive but it seems to has a long start-up time, especially with external JavaScript (eg:map).
Although I'm comfortable using jQuery in a web site, I have concerns about the maturity of jQuery Mobile. (I haven't tested it yet)
I have no idea about Dojo's mobile framework.
Which of these alternatives do you like? Why?
So what exactly are you requirements? Each framework has different several advantages and disadvantages....
Me personally I use Jquery Mobile, which is now at it's first official release. Don't let version numbers fool you, this has been developed 1 year long and actually works pretty good!
The others provide different capabilities:
sencha is based on javascript controls - you create the whole layout from within javascript using JSON notation for properties/actions/events
jqm allows you to use your "standard" HTML and enhances it "auto-magically". In my opinion this is the closest to HTML you'll ever get
Dojo is more about MVC and allows a more structured environment. Haven't used it personally so I can't say too much about it...
Hope this helps
I'm starting a fairly complex grails app but am a bit slow hand-coding nice user interface pages directly in CSS/HTML. Several people have recommended IntelliJ for the grails app development, and I plan to use mostly grails scaffolding for the admin portion of the site.
Can you recommend an approach or tools for building a nice UI fairly fast?
Thanks
P.S. Eventually I plan to build "skinnier" mobile version as well.
One approach might be to continue to use the grails sitemesh main.gsp and just concentrate on your functionality using the scaffold-ed pages as examples. Once you are ready to tackle the style aspect you can deviate from the grails main.gsp template and create your own tailored for your look and feel.
If your complexity includes a fairly custom UI, I don't think your going to get a free lunch. You'll have to break down and code the UI.
I'm currently using jQuery UI coupled with jqGrid to get some fairly sophisticated grid / tree behavior in my UI with not too much html coding. I'm also using the jQuery UI Layout Plugin to manage pane layout and make my app look/feel more like an app rather than a page. Grails plays real nice with the ajax needs of jqGrid.