简体   繁体   English

jQuery Repeater,如何在底部创建“创建按钮”?

[英]Jquery Repeater, how to make the 'create button' at the bottom?

I understand that the data-repeater-create="" must be inside the id="left_repeater" , otherwise it will not function as a create button. 我了解到data-repeater-create=""必须位于id="left_repeater" ,否则它将无法用作创建按钮。 Is there a way that the button will function outside the id="left_repeater" or id="right_repeater" ? 有没有办法使按钮在id="left_repeater"id="right_repeater" id="left_repeater"之外id="left_repeater"

My goal is when I click add left button, it will only create the left input and vise versa for the add right button. 我的目标是当我点击add left按钮,它只会创造了左输入端,反之亦然add right按钮。 Both of the button is at the very bottom. 这两个按钮都在最底部。

JS fiddle link to see the codes JS小提琴链接查看代码

 $('#left_repeater').repeater({ show: function() { $(this).slideDown(); }, }); $('#right_repeater').repeater({ show: function() { $(this).slideDown(); }, }); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.repeater/1.2.1/jquery.repeater.min.js"></script> <div id="left_repeater"> <div data-repeater-list="left_items"> <div data-repeater-item> <div class="row"> <div class="col-6"> <input type="text" name="name" class="form-control form-control-sm m-input" placeholder="left"> </div> <div class="col-6"> </div> </div> </div> </div> <!-- <div data-repeater-create="" class="btn btn-sm btn-success"> <span><i class="la la-plus"></i><span>Add</span></span> </div> --> </div> <div id="right_repeater"> <div data-repeater-list="right_items"> <div data-repeater-item> <div class="row"> <div class="col-6"> </div> <div class="col-6"> <input type="text" name="name" class="form-control form-control-sm m-input" placeholder="right"> </div> </div> </div> </div> <div data-repeater-create="" class="btn btn-sm btn-success"> <span><i class="la la-plus"></i><span>Add</span></span> </div> </div> <div class="row"> <div class="col-6 text-center"> <div data-repeater-create="" class="btn btn-sm btn-success"> <span><i class="la la-plus"></i><span>Add Left</span></span> </div> </div> <div class="col-6 text-center"> <div data-repeater-create="" class="btn btn-sm btn-success"> <span><i class="la la-plus"></i><span>Add Right</span></span> </div> </div> </div> 

Place the #left_repeater inside div container. 将#left_repeater放入div容器中。

<div class="container">
   <div id="left_repeater">
     .....
   </div>
</div>

add CSS style to this 为此添加CSS样式

.container {
  display: flex;
}

https://jsfiddle.net/y1bpot5n// https://jsfiddle.net/y1bpot5n//

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM