EDIT 4
There’s a module defined in (from Foundation 3 package) app.js:
(function($, window, undefined) {
'use strict';
var $doc = $(document), Modernizr = window.Modernizr;
$(document).ready(function() {
$.fn.foundationAlerts ? $doc.foundationAlerts() : null;
// ...
$.fn.foundationClearing ? $doc.foundationClearing() : null;
$('input, textarea').placeholder();
});
// touch support detction is omitted
})(jQuery, this);
I tried to interpret it to the next form:
BOOTSTRAP.JS
require.config({
paths: {
// other paths then..
'foundation': '../libs/zurb'
},
shim: {
'foundation/jquery.foundation.topbar': { deps: ['jquery'] },
'foundation/jquery.foundation.accordion': { deps: ['jquery'] },
// ..all that stuff..
'foundation/jquery.placeholder': { deps: ['jquery'] }
}
});
require(['domReady', 'app'], function(domReady, app) {
domReady(function() {
app.initialize();
});
});
APP.JS
Well.. I found that this doesn’t work as it was expected:
define(
[
'jquery',
'underscore',
'backbone',
'routing/AppRouter',
'foundation/modernizr.foundation',
'foundation/jquery.foundation.accordion',
// all that foundation scripts...
'foundation/jquery.placeholder'
],
function($, _, Backbone, AppRouter) {
return {
initialize: function() {
var $doc = $(document);
// these things fail
$.fn.foundationAccordion ? $doc.foundationAccordion() : null;
// ...
$.fn.placeholder ? $('input, textarea').placeholder() : null;
// this works great!
$('#slider').orbit();
// router/controller initialization
AppRouter.initialize();
}
};
}
);
When the page gets loaded one can see that foundation's ui elements don’t work at all (accordion doesn’t expand its panels etc).
When I entered $(document).foundationAccordion() in Chrome console (page had been loaded by the time) it enabled UI elements on a page.
Help!!
After rereading Tom’s answer I finally got it! Though this is not a complete picture I’ll share what I’ve got)
My
bootstrap.jsfile has changed:So it was trully helpful to look inside each of foundation’s scripts to see what they’ve got.
Then I was able to write the following:
Then I just wrapped all of this within:
Voila!!!