admin管理员组

文章数量:1410725

This is my page.

And i got an error is

Uncaught TypeError: undefined is not a function 'appendTo'

I have not idea what happend to this.

Error occur in

$('#img-wrapper-tmpl').tmpl( {itemsCount : itemsCount} ).appendTo($rgGallery);

Can you please help this?

Thanks in advence.

This is my page.

And i got an error is

Uncaught TypeError: undefined is not a function 'appendTo'

I have not idea what happend to this.

Error occur in

$('#img-wrapper-tmpl').tmpl( {itemsCount : itemsCount} ).appendTo($rgGallery);

Can you please help this?

Thanks in advence.

Share edited Apr 24, 2014 at 10:08 Irvin Dominin 31k9 gold badges80 silver badges113 bronze badges asked Apr 24, 2014 at 10:08 Nicky LiuNicky Liu 1572 silver badges13 bronze badges 7
  • 2 $('#img-wrapper-tmpl').tmpl( {itemsCount : itemsCount} ) returns an empty array []. Therefore, trying to append it anywhere isn't going to work – Lee Taylor Commented Apr 24, 2014 at 10:12
  • 2 it should like .appendTo($("#rgGallery")) – neel shah Commented Apr 24, 2014 at 10:12
  • 1 Which jquery.tmpl library do you use? – VisioN Commented Apr 24, 2014 at 10:13
  • 2 I can't find any element for $('#img-wrapper-tmpl'); what this selector is pointing to? – Irvin Dominin Commented Apr 24, 2014 at 10:14
  • 1 @neelshah var $rgGallery = $('#rg-gallery') is in the code, so that is fine. – Lee Taylor Commented Apr 24, 2014 at 10:14
 |  Show 2 more ments

3 Answers 3

Reset to default 5

You don't have #img-wrapper-tmpl element in your page, that's the reason your selector is returning null or empty array and based on which you got this error.

$rgGallery.append($('#img-wrapper-tmpl').tmpl( {itemsCount : itemsCount} ));

I believe that you're missing a parameter to your .tmpl() function.

$.tmpl( template, {itemsCounts : itemsCount}).appendTo($rgGallery); 

or

$.tmpl($('#img-wrapper-tmpl'), {itemsCounts : itemsCount}).appendTo($rgGallery);

Where template is a variable that contains the HTML markup of what you to render. Based on your code, you're using the this plugin.

Re: You should also specify $('#img-wrapper-tmpl')

本文标签: javascriptUncaught TypeError undefined is not a function 39appendTo39Stack Overflow