:::

3. SheepIt用法-動態新增樣板

  1. js部分
    <script type="text/javascript" src="class/jquery.sheepItPlugin.js"></script>
    
      <script type='text/javascript'>
        $(document).ready(function() {
          var  AddTeamClass= $('#AddTeamClass').sheepIt({
               separator: '',
               allowRemoveLast: true,
               allowRemoveCurrent: true,
               allowRemoveAll: true,
               allowAdd: true,
               allowAddN: true,
               maxFormsCount: 200,
               minFormsCount: 1,
               iniFormsCount: 1,
          });
    
        });
    
      </script> 
    
    
  2. html部分
    1. )撰寫欲複製的樣板,命名id="AddTeamClass"
      <div id="AddTeamClass" >
      
                <div id="AddTeamClass_template" class="well">
                  <div class="row-fluid">
                    <label class="span2">
                      欄位名稱
                    </label>
                    <div class="span8">
                      <input type="text" name="MinClassNum[#index#]" id="MinClassNum_#index#" class="span5 validate[required]" value="<{$MinClassNum}>" placeholder="<{$smarty.const._MD_ACTIVITY_MINCLASSNUM}>" >~
                      <input type="text" name="MaxClassNum[#index#]" id="MaxClassNum_#index#" class="span5 validate[required]" value="<{$MaxClassNum}>" placeholder="<{$smarty.const._MD_ACTIVITY_MAXCLASSNUM}>" >
                    </div>
                  </div>
                 
                  <div class="row-fluid">
                    <div class="text-right">
                      <a id="AddTeamClass_remove_current" class="btn btn-danger">
                        刪除
                      </a>
                    </div>
      
                  </div>
                </div>
      
                <div id="AddTeamClass_noforms_template"></div>
      </div>
    2. )加入欲新增一組樣板的控制項id="AddTeamClass_controls"
      <div class="text-right" id="AddTeamClass_controls">
           <div id="AddTeamClass_add" >
               <a class="btn btn-success" >
                 <label>新增一組樣板</label>
               </a>
           </div>
      </div>