编辑 4
(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);
我试图将其解释为下一种形式:
引导程序.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
好吧..我发现这不像预期的那样工作:
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();
}
};
}
);
当页面被加载时,可以看到foundation's
ui 元素根本不起作用(手风琴不会扩展其面板等)。
当我进入$(document).foundationAccordion()
Chrome 控制台(页面已经加载)时,它UI elements
在页面上启用。
帮助!!