File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change 3737 * objects behavior.
3838 */
3939 window . infinite . Collection = function ( collection , prototypes , options ) {
40- this . $collection = $ ( collection ) ;
41- this . internalCount = this . $collection . children ( ) . length ;
42- this . $prototypes = prototypes ;
43-
4440 this . options = $ . extend ( {
4541 allowAdd : true ,
4642 allowDelete : true ,
5248 keepScripts : false
5349 } , options || { } ) ;
5450
51+ this . $collection = $ ( collection ) ;
52+ this . internalCount = this . $collection . find ( this . options . itemSelector ) . length ;
53+ this . $prototypes = prototypes ;
54+
5555 this . initialise ( ) ;
5656 } ;
5757
Original file line number Diff line number Diff line change 132132 equal ( collection . internalCount , 4 ,
133133 'Internal count is incremented when adding' ) ;
134134 } ) ;
135-
135+
136136 test ( "Keep scripts in prototype html" , function ( ) {
137137 var collection = setUpCollection ( '#markup .list-collection-with-prototype-scripts' , {
138138 keepScripts : true
182182 equal ( result . length , 1 , 'addToCollection returned the row' ) ;
183183 } ) ;
184184
185+ test ( "Custom html structure" , function ( ) {
186+ var collection = setUpCollection ( '#markup .list-collection-different-html-structure' ) ;
187+ equal ( collection . internalCount , 1 ,
188+ 'Internal count is correctly initialized' ) ;
189+ } ) ;
190+
185191 function setUpCollection ( selector , options ) {
186192 var $fixture = $ ( '#qunit-fixture' ) ;
187193
Original file line number Diff line number Diff line change 5555 <a class="custom_remove_item">Remove</a>
5656 </div> "> Add</ a >
5757 </ div >
58+ < div class ="list-collection-different-html-structure ">
59+ < table class ="collection ">
60+ < thead >
61+ < tr >
62+ < th > Email</ th >
63+ < th > Remove</ th >
64+ </ tr >
65+ </ thead >
66+ < tbody >
67+ < tr class ="item input-append " data-original >
68+ < td > < input type ="email " name ="formb[0] " id ="formb_0 " /> </ td >
69+ < td > < a class ="custom_remove_item "> Remove</ a > </ td >
70+ </ tr >
71+ </ tbody >
72+ </ table >
73+
74+ < a class ="add_item " data-customprototype ="<tr class="customitem input-append">
75+ <td><input type="email" name="formb[__customname__]" id="formb___customname__" /></td>
76+ <td><a class="custom_remove_item">Remove</a></td>
77+ </tr> "> Add</ a >
78+ </ div >
5879</ div >
5980
6081</ body >
You can’t perform that action at this time.
0 commit comments