vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

Vuejs no catch attached events to elements added dinamically #372

Closed Danjavia closed 9 years ago

Danjavia commented 9 years ago

I try to catch a click event from a button added dinamically to the site via jQuery but nothing happens. Some idea about this issue.

Thanks!

azamat-sharapov commented 9 years ago

You should add button via Vue, not jQuery.

Danjavia commented 9 years ago

Sorry for the question, How can I add element in vuejs?

I want to make this:

$( '.owl-carousel' ).append( '<i class="remove" v-on="click: removeSomething">remove</i>' );

Where 'Owl-carousel' are multiple carousels in the page

azamat-sharapov commented 9 years ago

You can use v-if to insert/remove any HTML block.

Danjavia commented 9 years ago

I try this

$( document ).on( 'click', '.owl-carousel' , vm.RemoveSomething );

Thanks guys!