本文介绍了Aurelia popover复选框已选中.绑定未反映在视图模型上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经在弹出窗口中实现了复选框.在那里,我们使用了check.bind,但是在视图模型中,它并没有反映出复选框更改后的值.

We have implemented checkbox in popover. There we are using checked.bind , but in the view model its not reflecting its value on change of the checkboxes.

样本要点运行提供如下:

Sample Gist Run Provided below:

Gist Run

预先感谢

推荐答案

以编程方式注入的HTML需要手动进行编译

我先前提供给您的与bootstrap的集成无法做到这一点. bootstrap插件分配弹出框的innerHTML属性,并在aurelia的渲染管道之外执行此操作.因此,HTML不是由aurelia编译的,这就是为什么绑定(以及其他aurelia行为)无法正常工作的原因.

Programmatically injected HTML needs to be compiled manually

The integration with bootstrap I provided to you earlier cannot do this. The bootstrap plugin assigns the innerHTML property of the popover and it does this outside of aurelia's rendering pipeline. The HTML is therefore not compiled by aurelia, which is why bindings (and other aurelia behaviors) will not work.

只要您遵循约定(例如自定义元素),模板框架就会自动为您解决此问题.在任何其他情况下,您都需要手动使用ViewCompiler.

The templating framework takes care of this for you automatically as long as you are following conventions (such as custom elements). In any other case you'll need to manually work with the ViewCompiler.

如果您有兴趣,您可以在此要点中看到一个示例,该示例包含以编程方式生成的HTML .如果您想了解更多有关此问题的信息,也请参见此问题.但是,在这种情况下,我不建议这样做.

In case you're interested, you can see an example with programmatically generated HTML in this gist. Also see this question if you want to know more about it. I do not recommend it in this scenario however.

工具提示(或弹出窗口)就是:有关如何使用该工具的提示.它只需要简单的标记,文本和样式(当然这在某种程度上是主观的,并且有些人可能会不同意)

A tooltip (or popover) is just that: a tip on how to use the tool. It should not need more than some plain markup, text and styling (of course this is subjective to some degree, and some people may disagree)

对于收集页面或屏幕之间的用户输入,我认为模态对话框更合适,因为它具有弹出"对话框的属性.并取消强调屏幕的其余部分,直到用户继续操作或取消操作为止.

For collecting user input in-between pages or screens, I'd argue a modal dialog is a better fit because of its property to "pop out" more and to de-emphasize the rest of the screen until the user either proceeds or cancels.

更重要的是,通过使用 aurelia-dialog ,您的绑定和行为将简单地起作用,因为,这是aurelia插件:-)

More importantly, by using aurelia-dialog your bindings and behaviors will simply work because, well, it's an aurelia plugin :-)

这篇关于Aurelia popover复选框已选中.绑定未反映在视图模型上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 12:42