KnockoutJS - 地图插件
我正在使用带有 Knockout 的映射插件,这很棒,对我来说非常容易。
但是,如果我想在将某个值推送到视图之前对其执行一组操作该怎么办?
假设我从 REST 调用返回一个“日期”字符串,我可以通过执行 viewModel.date 使用映射插件在我的视图中引用该字符串......
但是,如果我想在数据字符串被删除之前对其进行编辑该怎么办传递给映射插件?
Im using the mapping plugin with Knockout which is great, makes it very easy for me.
However what if I want to perform a set of operations on a value prior to it being pushed out to the view?
Say I'm getting a 'date' string back from a REST call, I can reference that in my view using the mapping plugin by doing viewModel.date....
However what if I wanted to edit the data string prior to it being passed to the mapping plugin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
映射插件接收一个 JSON 字符串。只要您的编辑不改变结构,就没有问题。
我执行你所描述的精确操作。当我的 Ajax 调用返回数据时,我会在发送到映射插件之前修改接收到的日期字符串。
The mapping plugin receives a JSON string. As long as your edits don't change the structure, it has no problem.
I do exact operations you describe. When data is returned from my Ajax call, I modify the received date strings before sending into the mapping plugin.