In my Laravel application, I have made a component in Vue. The component itself is rendering properly, but the click handler is not firing. I have read many articles on the issue, but can't find the solution.(https://prnt.sc/tyiwmh + https://prnt.sc/tyiwwb + https://prnt.sc/tyix8l)
<template>
<div class="item border rounded-lg p-3">
<header>
<h2 class="mb-3">John Doe</h2>
<div class="arrows" v-on:click="showContent">
<img src="storage/img/chevron-down-light.svg" alt="" class="arrow-down">
<img src="storage/img/chevron-up-light.svg" alt="" class="arrow-up">
</div>
</header>
<div class="item-content" v-if="visible">
<div class="content-1">
<ul>
<li><b>Email:</b> john.doe#hotmail.com</li>
<li><b>Tel:</b> 0497 99 88 77</li>
</ul>
</div>
<hr>
<div class="content-2">
<ul>
<li><b>Vertrekplaats:</b> Ark van Noƫ</li>
<li><b>Aankomstplaats:</b> Watermolen Grobbendonk</li>
</ul>
</div>
<hr>
<div class="content-3">
<ul>
<li>2 enkelzitkajaks</li>
<li>3 dubbelzitkajaks</li>
<li>0 canadese kano's</li>
<li>2 zwemvesten</li>
<li>3 tonnetjes</li>
</ul>
</div>
<hr>
<div class="content-4">
<h3>Extra info:</h3>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Incidunt fuga dignissimos hic? Velit, ea aliquam! Consequuntur provident vitae, hic repudiandae, animi, ipsa ullam quidem accusamus vero ipsum aut porro nostrum.
</p>
</div>
</div>
</div>
</template>
<script>
export default {
data: function() {
return {
visible: false
}
},
methods: {
showContent: function() {
console.log('the button is clicked');
}
}
}
</script>
This might help no method necessary:
<div class="arrows" #click="visisble = !visible">
<img #click="visisble = !visible"
:src="'storage/img/chevron-' + (visible ? 'down-light.svg':'up-light.svg')"
alt=""
:class="'arrow-' + (visible ? 'down' : 'up' )">
</div>
Related
I will try two scalize id however only one more worked. Every time second scalize function worked. How can I use one more scalize in one page. I want use scalize in repater.
I will try two scalize id however only one more worked. Every time second scalize function worked. How can I use one more scalize in one page. I want use scalize in repater.
`
<div class="scalize" id="scalize2">
<!-- Start Popover Template -->
<div id="content6" class="content center top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">4</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content4" class="content right top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">5</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content5" class="content right bottom">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">6</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
</div>
</div>
<!-- End Popover Template -->
<img src="img/deneme.jpg" alt="" class="target">
<!-- Start Item Point -->
<div class="item-point item-point2" data-top="121" data-left="922" data-popover="#content4">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point2" data-top="333" data-left="462" data-popover="#content5">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point2" data-top="444" data-left="546" data-popover="#content6">
<div></div>
</div>
<!-- End Item Point -->
</div>
<div class="scalize" id="scalize3">
<!-- Start Popover Template -->
<div id="content1" class="content right top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">1</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content3" class="content right top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">2</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content2" class="content right bottom">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">3</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
</div>
</div>
<!-- End Popover Template -->
<img src="img/2.jpg" alt="" class="target">
<!-- Start Item Point -->
<div class="item-point item-point3" data-top="320" data-left="922" data-popover="#content1">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point3" data-top="180" data-left="462" data-popover="#content3">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point3" data-top="192" data-left="546" data-popover="#content2">
<div></div>
</div>
<!-- End Item Point -->
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#scalize2').scalize({
styleSelector: 'circle',
animationPopoverIn: 'fadeIn',
animationPopoverOut: 'fadeOut',
animationSelector: 'pulse2',
selector: '.item-point2',
getSelectorElement: function (el) {
$('.item-point2 .active').not($(el)[0]).find('.toggle2').click();
}
});
$('#scalize3').scalize({
styleSelector: 'circle',
animationPopoverIn: 'fadeIn',
animationPopoverOut: 'fadeOut',
animationSelector: 'pulse2',
selector: '.item-point3',
getSelectorElement: function (el) {
$('.item-point3 .active').not($(el)[0]).find('.toggle3').click();
}
});
});
</script>
`
I am trying to show product using axois function , i have no idea how can i get data in axois by using for loop Does anyone have an idea please help me thanks.
please check response in console. https://ibb.co/YhqMsYZ
controller
public function store(Request $request)
{
$products = Product::with('productColorGallary')->where('status', 1)->get();
$data = [
'product' => $products
];
return response()->json($data, 200);
}
jquery script
let url = "{{route('products.store')}}";
axios.get(url, {
params:{
}
}).then((res)=>{
let product =res.data;
// console.log(product);
for(var i =0; i< product.length; i++)
{
$('#product').append(
`<div class="col-md-4 col-sm-6 col-6">
<div class="wallprodCard">
<div class="prodcardImage">
<img src="{{url('')}}/assets/images/wallpapers/wallpaper-1-01.jpg" alt="">
<a class="prodcardFancy" href="{{url('')}}/assets/images/wallpapers/wallpaper-1-01.jpg" data-fancybox="images" data-caption="Flooring">
<i class="fa fa-search-plus">
</i>
</a>
</div>
<div class="prodcardDescp">
<a href="{{url('')}}/wallpaper-details">
<h4 class="prodcardtitle">product name
</h4>
</a>
<p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</div>
</div>
`);
}
});
});
html view
<div class="tab-content">
<div class="tab tab-active" data-id="tab1">
<div class="row">
<div id="product"> </div>
</div>
</div>
<!--end of tab one-->
</div>
as res.data this is not product array
use this
let product =res.data.product;
as ur loop in javascript and and u r using `` this operator so u can use
string text ${expression} string text ref link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
$('#product').append(
`<div class="col-md-4 col-sm-6 col-6">
<div class="wallprodCard">
<div class="prodcardImage">
<img src="{{url('')}}/assets/images/wallpapers/wallpaper-1-01.jpg" alt="">
<a class="prodcardFancy" href="{{url('')}}/assets/images/wallpapers/wallpaper-1-01.jpg" data-fancybox="images" data-caption="Flooring">
<i class="fa fa-search-plus">
</i>
</a>
</div>
<div class="prodcardDescp">
<a href="{{url('')}}/wallpaper-details">
<h4 class="prodcardtitle">product name
</h4>
</a>
<p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</div>
</div>
${dynamicdata} // here u can use your javascript variable
`);
i find this useful and it will be worth trying it. in your component, you can initialize an empty array in the data() methods. assume you use an array called products,then this is how your script tag should be
<script>
export default{
data(){
return{
//now the empty array
products:[]
}
},
methods:{
getProducts:function(){
axios.get(url).then((response)=>{
this.products=response.data
//this saves the json data in the array
//you can then catch the error
//then check the html above
})
}
},
created(){
this.getProducts()
//
}
}
</script>
<div class="row">
<!-- the loop will create n numbers of elements with a col-sm-4 class for all length of products-->
<div class="col-sm-4 col-sm-6 col-6" v-for="product in products" :key="product.id">
<div class="col-md-4 col-sm-6 col-6">
<div class="wallprodCard">
<div class="prodcardImage">
<img :src="assets/images/wallpapers/wallpaper-1-01.jpg" alt="">
<a class="prodcardFancy" href="assets/images/wallpapers/wallpaper-1-01.jpg" data-fancybox="images" data-caption="Flooring">
<i class="fa fa-search-plus">
</i>
</a><!--Kindly Note thatif this field is dynamic, you mightwant to bind the href attribute to the dynamic value ie. the a href should be a :href="dynamic value"-->
</div>
<div class="prodcardDescp">
<a href="/wallpaper-details"><!--Kindly Note thatif this field is dynamic, you mightwant to bind the href attribute to the dynamic value ie. the a href should be a :href="dynamic value"-->
<h4 class="prodcardtitle">product name
</h4>
</a>
<p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</div>
</div>
</div>
</div>
I have two different div for two different blogs. One need to be only once, and the second one need to be print again and again. I am not able to write the loop for the same. So the first section need to get rendered once and second needs to get repeated again and again.
I have tried many loops and methods but none of them are working properly for me.
Not able to form any loop.
<section class="blog_main">
<div class="blog_left">
<img src="uploads/blogs/<?php echo $mythical[0]->image;?>">
</div>
<div class="blog_right">
<h1>Scaling design sprints: Spreading the gospel 4 min read</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In quas similique atque labore illum libero vero
sit, esse adipisci quis accusantium quisquam eos velit corporis doloremque soluta ducimus ipsum
voluptas?</p>
<h4>4 min read.</h4>
<a href="#" class="author">ARTICLE BY <span>DANIEL SPATZEK</span> IN <span>WEB DESIGN</span> - OCTOBER
02</a>
<ul>
<li><i class="fab fa-facebook-f"></i></li>
<li><i class="fab fa-instagram"></i></li>
<li><i class="fab fa-twitter"></i></li>
<li><i class="fab fa-pinterest-p"></i></li>
</ul>
</div>
</section>
<section class="same_sec">
<div class="row no-gutters">
<?php
if(count($mythical)>0){
foreach($mythical as $mythicals){
?>
<div class="col-md-3">
<a href="<?php echo base_url();?>home/blog_detail/<?php echo $mythicals->slug;?>">
<div class="small_curve_section">
<div class="image_S">
<img src="uploads/blogs/<?php echo $mythicals->image;?>">
</div>
<div class="content_for_curve">
<h3><?php echo $mythicals->blog_heading;?></h3>
<div class="bookar_mark_White">
<i class="fas fa-bookmark"></i>
<div class="div_black">
<p><?php echo $mythicals->read_time;?>min read</p>
</div>
</div>
</div>
</div>
</a>
</div>
<?php }} ?>
</div>
Edit code like this..
"same_sec" will loop upto to the count($mythical) array.
<?php
if(count($mythical)>0){
foreach($mythical as $mythicals){
?>
<section class="same_sec">
<div class="row no-gutters">
<div class="col-md-3">
<a href="<?php echo base_url();?>home/blog_detail/<?php echo $mythicals->slug;?>">
<div class="small_curve_section">
<div class="image_S">
<img src="uploads/blogs/<?php echo $mythicals->image;?>">
</div>
<div class="content_for_curve">
<h3><?php echo $mythicals->blog_heading;?></h3>
<div class="bookar_mark_White">
<i class="fas fa-bookmark"></i>
<div class="div_black">
<p><?php echo $mythicals->read_time;?>min read</p>
</div>
</div>
</div>
</div>
</a>
</div>
</div>
</section>
<?php
}
}
?>
Here is the code with vue.js , laravel.......
I want 'h5' attribute value that is {{$subcategory->name}} in my vue app, So I can perform other purpose.
<div class="container" id = "showProd">
<div class = "row">
<div class = "row" align = "center" id = "flash">
<div class="tabpanel">
<ul class="nav nav-tabs" role="tablist">
#foreach($data['subcategories'] as $count => $subcategory)
<li role="presentation" #if($count == 0) class="active" #endif>
<a href="#tab-{{ $subcategory->id }}" aria-controls="#tab-{{ $subcategory->id }}" role="tab" data-toggle="tab" v-on:click = "greet">
<div class="card" id = "category_list" style="width: 17rem;"><img id = "product_image" class="card-img-top" src="/images/0a09d8530691a1c23a4e4f4ec3eeff2a.jpg" alt="Card image cap" style="height:170px;">
<div class="card-body" >
<h5 class="card-title" id = "product_name" >{{$subcategory->name}}</h5>
</div>
</div>
</a>
</li>
#endforeach
</ul>
<div class="tab-content">
#foreach($data['subcategories'] as $count => $subcategory)
<div role="tabpanel" #if($count == 0) class="tab-pane active" #else class="tab-pane" #endif id="tab-{{ $subcategory->id }}">
<h2>{{ $subcategory->name }}</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias enim obcaecati praesentium repellat. Est explicabo facilis fuga illum iusto, obcaecati saepe voluptates! Dolores eaque porro quaerat sunt totam ut, voluptas.</p>
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
<script>
new Vue({
el: '#showProd',
data: {
name: 'Vue.js'
},
methods: {
greet: function (event) {
// `this` inside methods point to the Vue instance
var val = this.
alert('Hello ' + this.name + '!')
}
}
});
</script>
You can generate the data object from laravel and use vuejs binding and constructs to generate the html. This means that you won't rely on blade templating for generating the html, but on vuejs.
data () {
return JSON.parse( '{{json_decode($data['subcategories'])}}' )
}
Now you need to update your template to use the info from data and not directly from php via blade.
<div class="container" id = "showProd">
<div class = "row">
<div class = "row" align = "center" id = "flash">
<div class="tabpanel">
<ul class="nav nav-tabs" role="tablist">
<li v-for="(subcategory, subindex) in subcategories" role="presentation" :class="{'active': subindex === 0}">
<a :href="'#tab-' + subcategory.id" :aria-controls="'#tab-'+ subcategory.id" role="tab" data-toggle="tab" v-on:click = "greet">
<div class="card" id = "category_list" style="width: 17rem;"><img id = "product_image" class="card-img-top" src="/images/0a09d8530691a1c23a4e4f4ec3eeff2a.jpg" alt="Card image cap" style="height:170px;">
<div class="card-body" >
<h5 class="card-title" id = "product_name" >{{subcategory.name}}</h5>
</div>
</div>
</a>
</li>
</ul>
<div class="tab-content">
<div v-for="(subcategory, subindex) in subcategories" role="tabpanel" :class="{'tab-pane': subindex === 0, 'active': subindex === 0}" #else class="tab-pane" :id="'tab-'+subcategory.id">
<h2>{{ subcategory.name }}</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias enim obcaecati praesentium repellat. Est explicabo facilis fuga illum iusto, obcaecati saepe voluptates! Dolores eaque porro quaerat sunt totam ut, voluptas.</p>
</div>
</div>
</div>
</div>
</div>
</div>
Also, don't rely on id's in vue. Use refs or rely on vue binding.
There are several solutions to this, this is one:
In your html add a ref to your h5
<h5 class="card-title" id = "product_name" ref="product_name_{{$count" >{{$subcategory->name}}</h5>
You could add a parameter to the greet function that will receive the index that has been clicked
greet: function (pIndex) { //
// `this` inside methods point to the Vue instance
console.log(this.$refs['product_name_'pIndex].textContent) // Here
alert('Hello ' + this.name + '!')
}
I'm new to bootstrap and not that long into coding.
I created a carousel in bootstrap but the image is centered in the middle. but i want it to spread over the whole carousel. How do i fix this?
And i want the text on it be on te picture on the left side. How can i do this? I tried with text-align but maybe i did it at the wrong line.
<div class="row dnd_bottomspace">
<div class="col-md-12">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Carousel indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item">
<h2>Slide 1</h2>
<div class="carousel-caption">
<img src="Materialien/erde.jpg" class="img-responsive">
<h3>Erster Slider</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
<div class="item">
<h2>Slide 2</h2>
<div class="carousel-caption">
<img src="Materialien/erde.jpg" class="img-responsive">
<h3>Zweiter Slider</h3>
<p>Aliquam sit amet gravida nibh, facilisis gravida odio.</p>
</div>
</div>
<div class="item">
<h2>Slide 3</h2>
<div class="carousel-caption">
<img src="Materialien/erde.jpg" class="img-responsive">
<h3>Dritter Slider</h3>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
</div>
</div>
<div class="item">
<h2>Slide 4</h2>
<div class="carousel-caption">
<img src="Materialien/erde.jpg" class="img-responsive">
<h3>Vierter Slider</h3>
<p>Aliquam sit amet gravida nibh, facilisis gravida odio.</p>
</div>
</div>
</div>
</div>
</div>
this part should be into class="item"
<img src="Materialien/erde.jpg" class="img-responsive">
any text describing the picture or something should be into class="carousel-caption".
if you want the text to be on the left side then
<div class="carousel-caption" style="text-align:left;">