Guest User

Untitled

a guest
Nov 19th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <form action="javascript:void(0);" method="get">
  2. <input type="search" placeholder="Search..." v-model="search" @keyup.enter="searchPost()" autofocus>
  3. </form>
  4.  
  5. <div class="panel panel-default" v-for="post in posts">
  6. <div class="panel-heading">
  7. <a :href="'/' + $route.params.trans + '/post/' + post.slug"><h3>{{ post.title }}</h3></a>
  8. <small class="date" v-if="timeLang =='en'">{{ post.created_at | formatDateEn }}</small>
  9. <small class="date" v-else-if="timeLang =='id'">{{ post.created_at | formatDateId }}</small>
  10. </div>
  11. <div class="panel-body">
  12. <img :src="'/images/post/' + post.post.image" class="img-single-page img-responsive" alt="" v-if="post.post.image">
  13. <p>{{post.body | strip_tags | trunCate}}</p>
  14. <a :href="'/' + $route.params.trans + '/post/' + post.slug" class="btn readmore">Read More</a>
  15. </div>
  16. </div>
  17. <script>
  18. export default {
  19.  
  20. data()
  21. {
  22. return {
  23. posts: {},
  24. }
  25. },
  26. created(){
  27. this.$on('fetchdata', this.fetchPost);
  28. },
  29. methods: {
  30. fetchPost() {
  31. axios.get('/' + this.$route.params.trans + '/search?search=' + this.search)
  32. .then(({data}) => {
  33. this.posts = data
  34. }
  35. }
  36.  
  37. const app = new Vue({
  38. el: '#app',
  39. router,
  40. data: {
  41. show: false,
  42. search: '',
  43. }
  44. methods: {
  45. searchPost() {
  46. this.$emit('fetchdata');
  47. }
  48. }
  49. });
Add Comment
Please, Sign In to add comment