问题标签 [canjs-map]

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 回答
896 浏览

javascript - CanJS 模型:attr 函数和嵌套数据

canJS 中,我可以使用 设置模型属性person.attr('name', 'John Doe');,但有时该属性包含嵌套数据,因此我需要执行以下操作:

在 canJS 中是否有更短的解决方案?

0 投票
2 回答
474 浏览

javascript - 了解 Canjs 控件示例

我正在查看用于控制的 Canjs 示例。

在这种情况下,Task 对象到底是什么?我尝试使用 can.Construct 创建任务,但是当值更改时它不会触发更新功能。

有人可以解释一下吗?

0 投票
2 回答
657 浏览

javascript - Validate Dynamic Object using can.Map.Validate

I was looking for form validation in CanJS and came to know about can.Map.Validate plugin http://canjs.com/docs/can.Map.validations.prototype.errors.html

In the below example taken from the documentation itself, we need to give the properties of the object like 'dueDate' before the creating of the object itself

Now my requirement is I want to build a Map which checks whether my field attribute is empty and returns me a suitable error. But the problem is, there are multiple forms on my page and formObject gets generated dynamically. Now in the above scenario before the creation of object itself, you need to allot the property in init method on which validation needs to be performed. It is not good for my requirement as the object is getting build and properties are unknown before the creation of the object. I searched over the web a lot but unable to crack it.

Providing the code for better understanding EJS File: login.ejs

Controller:

Is there any way of validating the dynamic object properties using ca.Map.Validate plugin? How can I access the instance object passed inside the init method?

Thanks in advance :)

0 投票
1 回答
60 浏览

canjs - 如何构造一个带有计算值的 can.Map,其行为类似于普通属性?

假设我有一张地图:

我想绑定foo另一个地图中的值。我可以:

但这并不符合我的预期。

  1. 我希望otherMap.attr('fizzle')返回bar,但它返回一个函数。我不得不打电话otherMap.attr('fizzle')()
  2. 我希望能够通过调用来更改值otherMap.attr('fizzle', 'moo'),但这不会更改计算值。相反,如果我想更改基础值,我必须调用otherMap.attr('fizzle')('moo').

有没有办法使用计算值创建一个映射,其行为类似于普通属性?

谢谢!

0 投票
0 回答
13 浏览

dictionary - jVectorMap 标记作为自定义模板 html

如何在 jVectorMap 中添加模板 html 作为标记?