EDIT 4
有一个模块定义在(来自Foundation 3
包裹)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
在一页上。
Help!!