0

I'm new to Grunt and the distribution process. I have a Yeoman generated app using the backbone generator, require.js and jQuery Mobile. It works fine with 'grunt serve' but when I run through the build and serve:dist, clicking on the jQuery Mobile / Backbone href links does not respond. I'm using backbone routing.

If I manually type the href URL, it works. If I do an Inspect Element on the href and click on the URL in the debug window, it also works.

Something must not be getting included in the dist but I'm at at loss as to what is missing and why. I don't have any errors in the console.

Here's my Gruntfile: http://codeshare.io/pHbSc

SeattleStephens
  • 587
  • 8
  • 20
  • I think the answer is that I shouldn't be deploying require.js with my app - https://github.com/yeoman/grunt-usemin/issues/112. Also a good post http://webdesignporto.com/3-steps-to-fully-automatized-javascript-environment-with-yeoman-and-require-js-for-lazy-people/ and discussion https://github.com/yeoman/grunt-usemin/issues/192. – SeattleStephens May 14 '14 at 17:33

2 Answers2

1

Make sure almond is being used. See https://github.com/gruntjs/grunt-contrib-requirejs/blob/master/docs/requirejs-examples.md

MrTorture
  • 810
  • 6
  • 8
0

The jQuery Mobile settings to disable it's own link binding handler were being set correctly when run under require.js and grunt but not with almond. I was setting these values on mobileinit:

define(['jquery'], function ($) {
    $(document).on("mobileinit", function () {

But the mobileinit call was never being made under almond. I moved the settings to my Backbone main.js file and now they're being set and the Backbone routing is working

$.mobile.linkBindingEnabled = false 
$.mobile.hashListeningEnabled = false
SeattleStephens
  • 587
  • 8
  • 20