问题标签 [chaplinjs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
30 浏览

javascript - 在 Django 项目中使用 ChaplinJS

我正在尝试在 Django 项目中构建 ChaplinJS。我已经下载了Chaplin Boilerplate并在浏览器中打开了index.html 。工作得很好(显示卓别林示例页面)。然后我将所有文件放入 Django 项目“前端”目录,并通过 django 的staticfiles 解析index.html 中 *.js 库的所有路径。当我现在从本地主机打开我的页面时,我得到的只是空屏幕。服务器控制台显示:

我还检查了浏览器中的 JS 控制台:创建了应用程序对象,但没有控制器或视图。我究竟做错了什么?

0 投票
1 回答
500 浏览

javascript - 无法使用 Backbone 的事件功能在 href 上捕获点击事件

0 投票
1 回答
104 浏览

javascript - 如何使用 Chaplin 和 Browserify 避免多余的 Backbone / jQuery init

将 Chaplin 与 Browserify 和 jQuery 一起使用需要您执行以下操作:

这必须每次都写require('chaplin')。如果你在任何使用 Chaplin 的模块中错过了一次,并且如果该模块首先被初始化,那么 Chaplin 将被破坏,因为它将初始化为使用没有 jQuery 的 Chaplin,但后来你最终设置Backbone.$jQuery并且 Chaplin 并不期待那样。

这将破坏的一个例子是卓别林的视图,它将被初始化为使用“appendChild”而不是“append”来表示容器方法。但是该元素将是一个没有 appendChild 的 jQuery 选择器。

有什么方法可以强制 Browserify 中的顺序,以便在使用卓别林的每个模块中都不需要这个样板代码?

0 投票
1 回答
24 浏览

jquery - 在卓别林应用程序中注册事件处理程序

在卓别林应用程序中,我有一个集合视图和一个项目视图的组合,并且我需要在集合级别和项目级别都可点击的按钮。集合表示为表,项目表示为行。这些按钮只是 <button id="id1">...</button> 里面有一个图标。所有 id 都是唯一的。

注册事件处理程序发生在视图的初始化方法中:@delegate 'click', 'button#id1', @handler。

在集合级别这有效(事件处理程序显示在 Chrome 调试工具中),但根据调试工具,项目级别的事件处理程序根本没有注册。我尝试将委托调用移动到渲染方法,但这给出了相同的结果。

我做错了什么,我可以做些什么来注册项目视图的事件?

0 投票
1 回答
55 浏览

javascript - Chaplin.js - 未捕获的类型错误:无法读取未定义的属性“未定义”

有时我会收到类似错误的错误。为什么会出现?

0 投票
1 回答
37 浏览

coffeescript - ChaplinJS + Brunch,我可以只生成一个 JS 文件吗?

我想优化基于 Chaplin + brunch (coffeescript) 构建的网站的加载时间。我如何打包所有内容,以便浏览器只能看到/加载一个 js 文件?

主要是工作流问题,不知道brunch本身能不能实现,还是应该依赖webpack甚至jspm等外部包。

0 投票
1 回答
63 浏览

backbone.js - Backbone/chaplinJS:如何检查对象中的键是否存在

Backbone/chaplinJS:如何检查对象中是否存在密钥。例如要检查键“numOfRooms”是否可用。

0 投票
1 回答
411 浏览

javascript - $(document).ajaxError 未在 401 上触发

我们有一个错误处理程序来发布消息。

其中一个 fetch 调用返回 401

当我检查响应时,状态为 401,但 response.json() 正在抛出“Uncaught (in promise) SyntaxError: Unexpected end of JSON input。”因此,ajaxError 没有触发。

预期行为:如果我没有从 fetch 调用中获得状态 200,我希望 document.ajaxError 发布消息。

我们有一个 wrapper.js 具有覆盖功能

我可以在这个函数中全局捕获这个异常吗?

0 投票
0 回答
39 浏览

javascript - Backbone subview containing view template

Our project uses Backbone and Chaplin, and it contains a bunch of components with models, views and sometimes multiple templates for each component depending of the case. We are refactoring the most basic ones into smaller components that provide event handling and a basic template, and for modals this would be a general dialog without any content inside it.

This basic version should be called into the modal view as a subview, and then one of the possible modal templates should be rendered inside the basic template. Currently all of the modal templates share this basic structure:

As every modal template shares the same basic structure, that is .modal > .modal-container > .modal-content, I want to split it up like this:

modalContainer

modalTemplates

The main idea is that the modal templates are inserted inside the modalContainer template, and the container must be a subview of the modal view. Which would be the best way to implement this taking into account performance?

0 投票
1 回答
77 浏览

orocrm - OroCrm:动态表单

我正在尝试使表单与 Oro 3.1.1 和 Symfony 3.4 一起使用。为了使表单动态,我使用 ajax 发布表单,使用一些侦听器并使用响应 html 字段更新页面,如 Symfony 文档中所述:https ://symfony.com/doc/current/form/dynamic_form_modification.html#dynamic -代提交的表格

我的问题是某些字段是 select2 或自动完成,因此它们与data-page-component-module. 我知道这些字段是在页面第一次渲染时通过 PageComponentrender()函数初始化的,但这在页面加载时运行,我不明白如何渲染来自 ajax 响应的新字段。

我在文档中没有找到任何关于重新渲染页面组件模块的信息,有没有办法可以page:update在 PageController 上触发事件?如果是这样,我怎样才能得到控制器的句柄?

基本上js代码是这样的:

所以我想触发一个事件,在从响应中替换 html 之后重建新字段。

提前致谢