Agnito / meteor-autogrow

Automatically grow and shrink textareas with the content as you type
Other
2 stars 0 forks source link

autogrow appears to not work when used through template.$ (versus global $) #1

Open nrser opened 9 years ago

nrser commented 9 years ago

i'm seeing an issue where this fails:

Template.PostsFull.onRendered(function(){
  this.$("textarea[name='body']").autogrow();
});

but this works fine:

Template.PostsFull.onRendered(function(){
  $("textarea[name='body']").autogrow();
});

there is only one textarea being rendered. when i use this.$, there is no response when entering newlines in the textarea, but when pressing delete i get this error:

jquery.js:1463 Uncaught TypeError: Cannot read property 'ownerDocument' of null
Sizzle.contains @ jquery.js:1463
jQuery.extend.clone @ jquery.js:5510
(anonymous function) @ jquery.js:5838
(anonymous function) @ jquery.js:141
jQuery.extend.map @ jquery.js:503
jQuery.fn.jQuery.map @ jquery.js:140
jQuery.fn.extend.clone @ jquery.js:5837
s @ autogrow.js:34
jQuery.event.dispatch @ jquery.js:4665
jQuery.event.add.elemData.handle @ jquery.js:4333

any idea what the issues is? i can work around it, but it seems like the top example should work.

thanks, Neil.

jasli2 commented 9 years ago

@nrser I also meets this issue. Did you solved it?

nrser commented 9 years ago

no... i am still using $ instead of template.$ as a work-around.

nrser commented 8 years ago

@jasli2 if you're still having problems, i think i ran into the same issue again (though using react now, so not sure) and was able to solve it by supplying the element as context like:

var $textarea = $(domElement);
$textarea.autogrow({context: $textarea});

that might help in your situation too.