From the Logs, Backbone now registers itself for AMD (Require.js) Since v1.1.1. Great, So I try to do the same for a module but there is something I don't understand. If we look at section 4 of annotated sources the sources, The module doesn't return the global Backbone. No need shim and window.Backbone is available. But How Backbone can not be undefined ? // Definition Backbone
从日志中,骨干现在注册自AMD(Require.js)自v1.1.1以来。 太棒了,所以我试着对模块做同样的事情,但有些东西我不明白。 如果我们看注释源的第4部分来源,模块不会返回全局骨干。 不需要垫片和窗口。可以使用骨架。 但是骨干怎么不能被定义? //定义骨干模块 define(['underscore', 'jquery', 'exports'], function(_, $, exports) { root.Backbone = factory(root, exports, _, $); }); //需要Backbone模块 req
I'm finally taking some time to formally document my Marionette code, but I'm running into some issues with JSDoc3 and Marionette modules. How would I go about documenting a Marionette module defined like this: //Module1.js define([... , 'views'], function(..., 'views'){ "usestrict"; //Marionette Module definition: return function(...marionette module params...){ .
我终于花了一些时间正式记录我的Marionette代码,但是我遇到了JSDoc3和Marionette模块的一些问题。 我将如何去记录这样定义的Marionette模块: //Module1.js define([... , 'views'], function(..., 'views'){ "usestrict"; //Marionette Module definition: return function(...marionette module params...){ ... } } 然后在文档中将其挂接到定义如下的视图: //views.js define([...], function
I've got a base view method for my application that has a close method. It works great up until the point where I have to document it; basically I'm putting in a needless function call in order to properly document it. As Backbone already has an initialize function, it makes no sense to call it again here, taking up lines of code.. but if I drop this function from the code then the doc
我有我的应用程序有一个密切的方法的基本视图方法。 它工作良好,直到我必须记录它为止。 基本上我正在进行一个不必要的函数调用,以便正确记录它。 因为Backbone已经有了一个初始化函数,所以在这里再次调用它是没有意义的,占用代码行......但是如果我从代码中删除这个函数,那么不会生成视图的文档。 我的代码如下所示: /** * @exports BaseView */ define(['backbone'], function( Backbone ) { 'use strict';
I have two applications (more to be added that may or may not use backbone + requirejs), both developed using backbone + requirejs. I want to create an eventbus on which both applications can publish and subscribe to specific events. I have considered a two options, both of which have their own inefficiencies. These include: Using the document object since this is common to all applications
我有两个应用程序(更多可能会添加,可能会或可能不会使用backbone + requirejs),都是使用backbone + requirejs开发的。 我想创建一个事件总线,在这两个应用程序可以发布和订阅特定事件。 我考虑过两种选择,这两种选择都有其自身的低效率。 这些包括: 使用文档对象,因为这对于页面上的所有应用程序都是通用的,而不管框架/体系结构如何: // Aggregator define([], function () { var eventAgg = document.getEl
I've been developing a Backbone app with different modules, and as it's now grown larger I'm looking to organise it with the AMD pattern and RequireJS. I've been looking at different tutorials and articles about how to go about this, I've seen a couple of different ways to define the dependencies and was wondering: is there any major difference between these two Module defin
我一直在开发具有不同模块的Backbone应用程序,并且随着它现在变得越来越大,我正在寻求用AMD模式和RequireJS来组织它。 我一直在看不同的教程和文章,关于如何去做这件事,我已经看到了几种不同的方式来定义依赖关系,并且想知道:这两个模块定义之间有什么主要区别,我个人认为第二个当涉及到大量的定义时,它更加整洁吗? define(function (require) { "use strict"; var $ = require('j
I'm still very confused about CommonJS, AMD and RequireJS. Even after reading a lot. I know that CommonJS (formerly ServerJS) is a group for defining some JavaScript specifications (ie modules) when the language is used outside the browser. CommonJS modules specification has some implementation like Node.js or RingoJS, right? What's the relation between CommonJS, Asynchronous Module
我仍然对CommonJS,AMD和RequireJS感到困惑。 即使阅读了很多。 我知道CommonJS(以前称为ServerJS)是一组用于在浏览器外部使用该语言时定义一些JavaScript规范(即模块)的组。 CommonJS模块规范有一些像Node.js或RingoJS的实现,对吧? CommonJS,异步模块定义(AMD)和RequireJS之间有什么关系? RequireJS是否实现了CommonJS模块定义? 如果是,那么AMD是什么? RequireJS实现AMD API(源代码)。 CommonJS是一
I'm trying to load Backbone and Underscore (as well as jQuery) with RequireJS. With the latest versions of Backbone and Underscore, it seems kind of tricky. For one, Underscore automatically registers itself as a module, but Backbone assumes Underscore is available globally. I should also note that Backbone doesn't seem to register itself as a module which makes it kind of inconsistent
我正在尝试使用RequireJS加载Backbone和Underscore(以及jQuery)。 使用Backbone和Underscore的最新版本,似乎有点棘手。 首先,Underscore自动将自己注册为一个模块,但Backbone假定Underscore在全球范围内可用。 我还应该注意到Backbone似乎并没有将自己注册为一个与其他库不一致的模块。 这是最好的main.js我可以拿出那些作品: require( { paths: { 'backbone': 'libs/backbone/backbone-require',
This question already has an answer here: Modify the URL without reloading the page 18 answers In newer browsers that support history.pushState you can replace the url without reloading. Lets say a user browses to http://example.com/ernie.html window.history.pushState({ foo: "bar" }, "page 2", "bert.html"); Will change the address bar to http://example.com/bert.html , but won't cause
这个问题在这里已经有了答案: 修改网址而不重新加载页面18个答案 在支持history.pushState较新浏览器中,您可以在不重新加载的情况下替换网址。 假设用户浏览http://example.com/ernie.html window.history.pushState({ foo: "bar" }, "page 2", "bert.html"); 将地址栏更改为http://example.com/bert.html ,但不会导致浏览器加载bert.html,甚至不检查bert.html是否存在。
Possible Duplicate: Modify the URL without reloading the page I found that in Facebook if I click the Notes or Music links on left section, only the central section gets refreshed while the URL is changed, from www.facebook.com to www.facebook.com/Notes. As I know, changing URL will trigger whole page reload. What magic does Facebook do to its web pages? The magic is history.pushState().
可能重复: 修改网址而不重新加载页面 我发现,如果点击左侧部分的Notes或音乐链接,则在Facebook中,只有中央部分在URL更改时被刷新,从www.facebook.com到www.facebook.com/Notes。 据我所知,更改网址将触发整个页面重新加载。 Facebook对其网页有什么魔力? 神奇的是history.pushState()。 例 假设http://mozilla.org/foo.html执行以下JavaScript: var stateObj = { foo: "bar" }; history.pushState(stateO
This question already has an answer here: Modify the URL without reloading the page 18 answers if (location.search) { location.href = location.protocol + "//" + location.host + location.pathname; } 这应该重新加载到当前的URL减去任何查询字符串。 var new_url = (window.location+'').replace(/?.*/,''); window.location = new_url; document.location.href=goodpart[0];
这个问题在这里已经有了答案: 修改网址而不重新加载页面18个答案 if (location.search) { location.href = location.protocol + "//" + location.host + location.pathname; } 这应该重新加载到当前的URL减去任何查询字符串。 var new_url = (window.location+'').replace(/?.*/,''); window.location = new_url; document.location.href=goodpart[0];