Polymer1.0中动态设置disabled
来源:互联网 发布:sql注入 and 1 1 编辑:程序博客网 时间:2024/05/13 15:52
我想在下面这个button上动态绑定一个disabled,是的这个button在满足某些条件时显示,不满足时隐藏。
<paper-button class="green approveButton" on-click="reviewArt" data-version="{{item.version}}">Approve</paper-button>
disabled="{{item.disabled}}"
的时候,这个button不论item.disabled是true还是false都会显示出来。
后来在网上搜到这个http://stackoverflow.com/a/23822215/2177408
里面提了两种解决方法,一种是disabled?="{{item.disabled}}",一种是disabled$="{{item.disabled}}"。经过测试,只有第一种有效。
http://stackoverflow.com/a/23822215/2177408
Binding to the disabled attribute can be done like this:
<button ... disabled?="{{ points == 0 }}">Content</button>
This ?
is special syntax introduced by Polymer to support binding to this kind of boolean attributes.
This does not work:
<button ... disabled="{{ points == 0 }}">Content</button>
Because it would result in
<button ... disabled="false">Content</button>
which would still disable the button.
For Polymer >= 1.0 the new syntax to use is:
<button ... disabled$="{{value}}">Content</button>
Note: value
already has to be a boolean as Marco pointed out below. Otherwise you have to create a function that would return points == 0
. See Data Binding Documentation here and Migration Guidehere for reference.
- Polymer1.0中动态设置disabled
- javascript中设置一组radio(checkbox等)的disabled
- iOS8中UIBarButtonItem的setTitleTextAttributes对Disabled颜色设置无效
- html中input设置为readonly与disabled的区别
- 设置disabled属性
- 按钮设置disabled
- 设置元素disabled属性
- 输入框中disabled="disabled"问题
- html中 disabled readonly
- 使用jQuery设置disabled属性
- jquery设置元素成为disabled
- JQuery设置和去除disabled
- easyui里的disabled设置
- vb.net中设置checkedlistbox控件指定行为disabled的初级解决方法
- 【iOS开发-103】解决方案:iOS8.1中UIBarButtonItem的setTitleTextAttributes对Disabled颜色设置无效
- html jsp中设置select disabled 当修改保存时,后台未读取到数据
- 【iOS开发-103】解决方案:iOS8.1中UIBarButtonItem的setTitleTextAttributes对Disabled颜色设置无效
- html中设置元素不可编辑的方法以及readonly与disabled区别
- 关于UIView的autoresizingMask属性的研究
- linux根文件系统树制作
- android xml操作
- Windows的OpenFileDialog双击文件选择时,系统crash
- .base .local .remote .backup 文件的含义
- Polymer1.0中动态设置disabled
- 如何给第三方人员提供oracle接口
- Oracle pl/sql编程 23---怎么用java调用oracle函数
- edittext输入类型inputtype
- sql developer如何连接mysql数据库
- 将一个目录下所有指定文件里面的特定字符串替换
- 弹层问题(与上一篇有关联)
- 【FastDev4Android框架开发】Android快速开发框架介绍(一)
- Java的反射机制和作用