Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: FadeIn/To and SlideDown new element

Here is the one line of code I use to push a new row to my container:

this.$el.append(new ItemView(item).render().el);

Where item is a Backbone.js model, render() creates and/or modifies the object and el is the html element. (The object is never displayed until rendering is complete)

How can I keep** new ItemView(item).render() **and store it in a variable, then fade and slide it into (the bottom) of my container?

Edit

Please keep in mind that this.$el is the container element.

like image 838
Nahydrin Avatar asked Feb 14 '12 16:02

Nahydrin


2 Answers

var rendered = new ItemView(item).render();

$(rendered.el).appendTo(this.$el).hide().fadeIn().slideDown();
like image 88
Linus Thiel Avatar answered Nov 17 '22 13:11

Linus Thiel


Set attribute to your element style="display: none;" so when you append it it wont be visible. Then after add exec fadein function and your element will be visible.

I hopt this helps.

like image 1
Senad Meškin Avatar answered Nov 17 '22 11:11

Senad Meškin