API Docs for: 0.2
Show:

JC.AutoChecked Class

全选/反选

require: JC.common

JC Project Site | API docs | demo link

input[type=checkbox] 可用的 HTML 属性

checktype = string
类型: all(全选), inverse(反选)
checkfor = selector
需要全选/反选的 checkbox
checkall = selector
声明 checkall input, 仅在 checktype = inverse 时才需要
checktrigger = string of event name
点击全选反选后触发的事件, 可选

Constructor

JC.AutoChecked

(
  • _selector
)

Parameters:

  • _selector Selector

    要初始化的全选反选的父级节点 或 input[checktype][checkfor]

Example:

       <h2>AJAX data:</h2>
       <dl class="def example24">
           <dt>checkall example 24</dt>
           <dd>
               <label>
                   <input type="checkbox" checktype="all" checkfor="dl.example24 input[type=checkbox]">
                   全选
               </label>
               <label>
                   <input type="checkbox" checktype="inverse" checkfor="dl.example24 input[type=checkbox]" checkall="dl.example24 input[checktype=all]">
                   反选
               </label>
           </dd>
           <dd>
               <label>
                   <input type='checkbox' value='' name='' checked />
                   checkall24_1
               </label>
               <label>
                   <input type='checkbox' value='' name='' checked />
                   checkall24_2
               </label>
               <label>
                   <input type='checkbox' value='' name='' checked />
                   checkall24_3
               </label>
               <label>
                   <input type='checkbox' value='' name='' checked />
                   checkall24_4
               </label>
               <label>
                   <input type='checkbox' value='' name='' checked />
                   checkall24_5
               </label>
           </dd>
       </dl>
       <script>
       $(document).delegate( 'button.js_ajaxTest', 'click', function(){
           var _p = $(this);
           _p.prop('disabled', true);
           setTimeout( function(){ _p.prop('disabled', false); }, 1000 );
           $.get( './data/initCheckAll.php?rnd='+new Date().getTime(), function( _r ){
               var _selector = $(_r);
               $( $( 'body' ).children().first() ).before( _selector );
               JC.AutoChecked( _selector );
           });
       });
       </script>

Item Index

Methods

Methods

getInstance

(
  • _selector
)
AutoChecked instance static

获取或设置 AutoChecked 的实例

Parameters:

  • _selector Selector

Returns:

AutoChecked instance:

init

(
  • _selector
)
static

初始化 _selector 的所有 input[checktype][checkfor]

Parameters:

  • _selector Selector

isAutoChecked

(
  • _selector
)
static

判断 selector 是否可以初始化 AutoChecked

Parameters:

  • _selector Selector

Returns:

bool

on

(
  • _evtName
  • _cb
)

使用 jquery on 绑定事件

Parameters:

Returns:

AutoCheckedInstance

selector

()

获取 显示 AutoChecked 的触发源选择器, 比如 a 标签

Returns:

selector

trigger

(
  • _evtName
)

使用 jquery trigger 绑定事件

Parameters:

Returns:

AutoCheckedInstance

update

()

更新 全选状态