ons-lazy-repeat error in OnsenUI 2
-
I used previous version and was ok. Example for jQuery from https://onsen.io/guide/overview.html#UsingLazyRepeat
but now it is retrieving error:angular.min.js:107 ReferenceError: MyDelegate is not defined at eval (eval at <anonymous> (http://localhost/www/components/monaca-onsenui/js/angular-onsenui.min.js:2:10925), <anonymous>:1:1) at Class.extend._getDelegate (http://localhost/www/components/monaca-onsenui/js/angular-onsenui.min.js:2:10909) at Class.extend.init (http://localhost/www/components/monaca-onsenui/js/angular-onsenui.min.js:2:10066) at new Class (http://localhost/www/components/monaca-onsenui/js/onsenui.min.js:3:22935) at http://localhost/www/components/monaca-onsenui/js/angular-onsenui.min.js:4:2064 at aa (http://localhost/www/components/monaca-onsenui/js/angular/angular.min.js:73:90) at K (http://localhost/www/components/monaca-onsenui/js/angular/angular.min.js:62:39) at g (http://localhost/www/components/monaca-onsenui/js/angular/angular.min.js:54:410) at K (http://localhost/www/components/monaca-onsenui/js/angular/angular.min.js:61:488) at g (http://localhost/www/components/monaca-onsenui/js/angular/angular.min.js:54:410) <ons-list-item modifier="chevron" class="list_respeak list__item list__item--chevron" ons-lazy-repeat="MyDelegate" style="-webkit-user-select: none; touch-action: pan-y; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
-
@Евгений-Гедройц Are you using jQuery or AngularJS? The error is for Angular but you are mentioning jQuery. Also, could you post your code preferably in a codepen?
-
Yes, my project has angular and jQuery. i’m using this code:
<ons-list> <ons-list-item modifier="chevron" class="list_respeak" ons-lazy-repeat="MyDelegate" style="height:40px"> </ons-list-item> </ons-list> <script> var hItem = 40; var MyDelegate = { createItemContent: function(index, oldContent) { if (oldContent) { return oldContent; } var $element = $("<div><span style='opacity: 0.7;'><ons-icon icon='fa-spinner' spin='true'></ons-icon> Загрузка респиков...</span></div>"); var request = $.getJSON('https://baconipsum.com/api/?type=meat-and-filler&sentences=1&callback=?', function(data) { $element.text(data[0]); }); $element.data('request', request); return $element[0]; }, destroyItemContent: function(index, element) { var request = $element.data('request'); request.abort(); }, calculateItemHeight: function(index) {return hItem;}, countItems: function(){ return 10000000; }, destroyItemContent: function(index, element) { console.log("Destroyed item " + index); } } //$('.list_respeak').children('.ng-scope').each(function(){ //console.log($(this).height); //if( $(this).height > hItem ){ //$(this).addClass('overflow'); //} //}); </script>
In Monaca is good(OnsenUI1) I exported my project to my localhost and changed OnsenUI2
If it’s not enough i’ll make codepan
-
@Евгений-Гедройц If you can make a codepen, I will play with it and try to figure out what is going on. Also, avoid using the script tag in code blocks because it makes everything faded out. @Leonardo-Augusto and I learned this the hard way. :smiley: