vue.js - Passing data from table row into bootstrap modals -
i'm creating vue js spa , trying create when click on table row, show modals with/showing data row clicked on.
here have created table
<tr class="cursor-pointer" @click="modalcontextmenu"> <td> <img :src="'/images/artikel/' + props.item.images + 'n.jpg'" class="img-rounded img-sm" v-if="props.item.images"> <img :src="'/images/image-articlen.jpg'" class="img-rounded img-sm" v-else> </td> <td>{{props.item.name}}</td> <td>{{props.item.category.name}}</td> <td>{{props.item.writter}}</td> <td v-html="$options.filters.checkstatus(props.item.publish)"></td> <td v-html="$options.filters.checkstatus(props.item.featured)"></td> <td>{{props.item.created_at | publishdate}}</td> </tr> at <tr> put @click methods make modal show , data want show modals data each <td> row / <tr>
right modalcontextmenu methods make modals visible/appear this
modalcontextmenu(){ this.modalshow= true; }
you can create data property data want show in modal.
data () { modaldata: '' } then can set property in onclick function.
html
<tr class="cursor-pointer" @click="modalcontextmenu(data)"> <td> <img :src="'/images/artikel/' + props.item.images + 'n.jpg'" class="img-rounded img-sm" v-if="props.item.images"> <img :src="'/images/image-articlen.jpg'" class="img-rounded img-sm" v-else> </td> <td>{{props.item.name}}</td> <td>{{props.item.category.name}}</td> <td>{{props.item.writter}}</td> <td v-html="$options.filters.checkstatus(props.item.publish)"></td> <td v-html="$options.filters.checkstatus(props.item.featured)"></td> <td>{{props.item.created_at | publishdate}}</td> </tr> js:
modalcontextmenu(data) { this.modaldata = data; this.modalshow= true; } then access data in modal using {{ modaldata }}.
Comments
Post a Comment