SeattleStephens
SeattleStephens

Reputation: 587

grunt serve:dist error with Backbone jQuery Mobile RequireJS

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

Upvotes: 0

Views: 124

Answers (2)

SeattleStephens
SeattleStephens

Reputation: 587

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

Upvotes: 0

Related Questions