API Docs for:
Show:

File: packages/bricksui-form/lib/checkbox.js

  1. /**
  2. @module bricksui
  3. @submodule bricksui-form
  4. */
  5. /**
  6. 拓展Ember.EasyForm.Input的CheckBox功能
  7. 提供复选框按钮组的功能
  8. 使用方式如:
  9. ```handlebars
  10. {{checkbox something modelBinding="model" propertyPath="something" elementsBinding="fruits" labelPath="name"}}
  11. ```
  12. @class Checkbox
  13. @namespace Ember.EasyForm
  14. @extends Ember.EasyForm.Input
  15. */
  16. var Checkbox = Ember.EasyForm.Input.extend({
  17. /**
  18. *初始化操作,模仿Ember.Component,将视图上下文设置为自身,并从Ember.EasyForm.Config中获取模板
  19. *@method init
  20. */
  21. init: function () {
  22. this._super.apply(this, arguments);
  23. this.set('templateName', this.get('wrapperConfig.checkboxTemplate'));
  24. this.set('context', this);
  25. this.set('controller', this);
  26. },
  27. /**
  28. * 标签属性
  29. * 如 elements为 [{key:1,value:"123"},{key:2,value:"234"}]需要将value值作为label展示,则只需设置labelPath为value
  30. * @property labelPath
  31. * @default null
  32. * @type string
  33. */
  34. labelPath: null,
  35.  
  36. /**
  37. * 绑定的Ember Data模型
  38. * @default null
  39. * @property model
  40. * @type object
  41. */
  42. model: null,
  43.  
  44. /**
  45. * 绑定模型中的hasMany属性,在elements复选框选中的对象将push到该属性中
  46. * @property propertyPath
  47. * @type string
  48. * @default null
  49. */
  50. propertyPath: null,
  51.  
  52. /**
  53. * 复选框的模型,必须为一个数组类型
  54. * 如 elements为 [{key:1,value:"123"},{key:2,value:"234"}]
  55. * @property elements
  56. * @default null
  57. * @type object
  58. */
  59. elements: null,
  60.  
  61. /**
  62. * @private
  63. */
  64. elementsOfProperty: function () {
  65. return this.get('model.' + this.get('propertyPath'));
  66. }.property()
  67.  
  68. });
  69.  
  70. export default
  71. Checkbox;