Magento 2 - Slick slider function not workingStrategry Infinite scrolling not working in Magento 1.9price filter Onresize function is not workingmagento 2: js function not working from template filejQuery css is not working for mobileHow to fire a function after get data from another function in JQuery?Magento price slider not workingMagento 2.2.2 - RequireJS domReady! not working with Slick Product Sliderjquery ajax not working in magento2How to add Slick Slider in Magento 2?ReferenceError: jQuery is not defined error owl Carousel slider

Do atomic orbitals "pulse" in time?

Extracting sublists that contain similar elements

Make all the squares explode

How many are the non-negative integer solutions of 𝑥 + 𝑦 + 𝑤 + 𝑧 = 16 where x < y?

How does noise-cancellation work in Mac laptops?

Page contents aligning weirdly in LaTeX/Overleaf

How can I answer high-school writing prompts without sounding weird and fake?

Was there ever any real use for a 6800-based Apple I?

How are one-time password generators like Google Authenticator different from having two passwords?

Why is “Ich wusste, dass aus dir mal was wird” grammitally correct?

Why does getw return -1 when trying to read a character?

Plastic-on-plastic lubricant that wont leave a residue?

Who was this character from the Tomb of Annihilation adventure before they became a monster?

Why in a Ethernet LAN, a packet sniffer can obtain all packets sent over the LAN?

How are Core iX names like Core i5, i7 related to Haswell, Ivy Bridge?

What food production methods would allow a metropolis like New York to become self sufficient

A curve pass via points at TiKz

Ex-manager wants to stay in touch, I don't want to

Reaction of borax with NaOH

Why not just directly invest in the holdings of an ETF?

Why is this int array not passed as an object vararg array?

Was this character’s old age look CGI or make-up?

What stroke width Instagram is using for its icons and how to get same results?

How did Thanos not realise this had happened at the end of Endgame?



Magento 2 - Slick slider function not working


Strategry Infinite scrolling not working in Magento 1.9price filter Onresize function is not workingmagento 2: js function not working from template filejQuery css is not working for mobileHow to fire a function after get data from another function in JQuery?Magento price slider not workingMagento 2.2.2 - RequireJS domReady! not working with Slick Product Sliderjquery ajax not working in magento2How to add Slick Slider in Magento 2?ReferenceError: jQuery is not defined error owl Carousel slider






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















Slick slider function is not working after ajax response, This is the order of my code. Firstly I got a product collection response, Then I wrote a slick slider function. but slider function is not working.



This is dom element in phtml file in which ajax response appear



<div class="category-products clearfix products wrapper grid products-grid">
<ol class="products list items product-items featured-collector featured-collector_<?php echo $categoryid; ?>">
</ol>
</div>


This is my js code



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);

require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
);









share|improve this question
























  • any console errors?

    – jafar pinjar
    May 8 at 10:00











  • There is no any error in my console.

    – Muhammad Anas
    May 8 at 10:01











  • where you are writing js code? in phtml or separate js file?

    – jafar pinjar
    May 8 at 10:03

















4















Slick slider function is not working after ajax response, This is the order of my code. Firstly I got a product collection response, Then I wrote a slick slider function. but slider function is not working.



This is dom element in phtml file in which ajax response appear



<div class="category-products clearfix products wrapper grid products-grid">
<ol class="products list items product-items featured-collector featured-collector_<?php echo $categoryid; ?>">
</ol>
</div>


This is my js code



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);

require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
);









share|improve this question
























  • any console errors?

    – jafar pinjar
    May 8 at 10:00











  • There is no any error in my console.

    – Muhammad Anas
    May 8 at 10:01











  • where you are writing js code? in phtml or separate js file?

    – jafar pinjar
    May 8 at 10:03













4












4








4








Slick slider function is not working after ajax response, This is the order of my code. Firstly I got a product collection response, Then I wrote a slick slider function. but slider function is not working.



This is dom element in phtml file in which ajax response appear



<div class="category-products clearfix products wrapper grid products-grid">
<ol class="products list items product-items featured-collector featured-collector_<?php echo $categoryid; ?>">
</ol>
</div>


This is my js code



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);

require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
);









share|improve this question
















Slick slider function is not working after ajax response, This is the order of my code. Firstly I got a product collection response, Then I wrote a slick slider function. but slider function is not working.



This is dom element in phtml file in which ajax response appear



<div class="category-products clearfix products wrapper grid products-grid">
<ol class="products list items product-items featured-collector featured-collector_<?php echo $categoryid; ?>">
</ol>
</div>


This is my js code



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);

require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
);






magento2 magento2.3 ajax jquery slick






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Muhammad Hasham

3,76731542




3,76731542










asked May 8 at 9:50









Muhammad AnasMuhammad Anas

9121322




9121322












  • any console errors?

    – jafar pinjar
    May 8 at 10:00











  • There is no any error in my console.

    – Muhammad Anas
    May 8 at 10:01











  • where you are writing js code? in phtml or separate js file?

    – jafar pinjar
    May 8 at 10:03

















  • any console errors?

    – jafar pinjar
    May 8 at 10:00











  • There is no any error in my console.

    – Muhammad Anas
    May 8 at 10:01











  • where you are writing js code? in phtml or separate js file?

    – jafar pinjar
    May 8 at 10:03
















any console errors?

– jafar pinjar
May 8 at 10:00





any console errors?

– jafar pinjar
May 8 at 10:00













There is no any error in my console.

– Muhammad Anas
May 8 at 10:01





There is no any error in my console.

– Muhammad Anas
May 8 at 10:01













where you are writing js code? in phtml or separate js file?

– jafar pinjar
May 8 at 10:03





where you are writing js code? in phtml or separate js file?

– jafar pinjar
May 8 at 10:03










2 Answers
2






active

oldest

votes


















4














Actually one of possible reason why it may not properly working because you don't add the slick after ajax success response. You just need to replace this, with your js code



require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();

// ******This is your slick code***********
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);


I hope this will help






share|improve this answer























  • let me try this, come back to you

    – Muhammad Anas
    May 8 at 10:08











  • Don't think it is as easy :)

    – Muhammad Anas
    May 8 at 10:14











  • @MuhammadAnas Adding to the answer, Might be take as future reference, In javascript code is execute sequentially, or line by line so in after Ajax call, request sent to the server but it not guarantee that result will come before next line of code execute, so better to wait for dependent code (in your case slick), so need to add code in success callback function which will execute after response came from server.

    – Kanhaiya lal
    yesterday


















3














It's likely your AJAX request is completing AFTER the slider is initialised, see if adding your Slick JS to your success callback helps:



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();

jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);

);
);


If so I recommend you split your JS up into Require JS modules rather than inlining it inside a template then you can keep them separate and still call it in your success callback. I see JS inside PHTML as a bad practice, it makes maintenance much harder and I think it prevents your JS from being cached.






share|improve this answer























  • your answer is also correct but I can mark anyone answer correct. Still +1 for your effort. Thanks :)

    – Muhammad Anas
    May 8 at 10:13











  • You're welcome :D

    – Ben Crook
    May 8 at 10:18











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273822%2fmagento-2-slick-slider-function-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Actually one of possible reason why it may not properly working because you don't add the slick after ajax success response. You just need to replace this, with your js code



require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();

// ******This is your slick code***********
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);


I hope this will help






share|improve this answer























  • let me try this, come back to you

    – Muhammad Anas
    May 8 at 10:08











  • Don't think it is as easy :)

    – Muhammad Anas
    May 8 at 10:14











  • @MuhammadAnas Adding to the answer, Might be take as future reference, In javascript code is execute sequentially, or line by line so in after Ajax call, request sent to the server but it not guarantee that result will come before next line of code execute, so better to wait for dependent code (in your case slick), so need to add code in success callback function which will execute after response came from server.

    – Kanhaiya lal
    yesterday















4














Actually one of possible reason why it may not properly working because you don't add the slick after ajax success response. You just need to replace this, with your js code



require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();

// ******This is your slick code***********
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);


I hope this will help






share|improve this answer























  • let me try this, come back to you

    – Muhammad Anas
    May 8 at 10:08











  • Don't think it is as easy :)

    – Muhammad Anas
    May 8 at 10:14











  • @MuhammadAnas Adding to the answer, Might be take as future reference, In javascript code is execute sequentially, or line by line so in after Ajax call, request sent to the server but it not guarantee that result will come before next line of code execute, so better to wait for dependent code (in your case slick), so need to add code in success callback function which will execute after response came from server.

    – Kanhaiya lal
    yesterday













4












4








4







Actually one of possible reason why it may not properly working because you don't add the slick after ajax success response. You just need to replace this, with your js code



require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();

// ******This is your slick code***********
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);


I hope this will help






share|improve this answer













Actually one of possible reason why it may not properly working because you don't add the slick after ajax success response. You just need to replace this, with your js code



require([
'jquery',
'magiccart/slick',
'alothemes'
], function($, slick)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();

// ******This is your slick code***********
jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();


);
);


I hope this will help







share|improve this answer












share|improve this answer



share|improve this answer










answered May 8 at 10:05









Muhammad HashamMuhammad Hasham

3,76731542




3,76731542












  • let me try this, come back to you

    – Muhammad Anas
    May 8 at 10:08











  • Don't think it is as easy :)

    – Muhammad Anas
    May 8 at 10:14











  • @MuhammadAnas Adding to the answer, Might be take as future reference, In javascript code is execute sequentially, or line by line so in after Ajax call, request sent to the server but it not guarantee that result will come before next line of code execute, so better to wait for dependent code (in your case slick), so need to add code in success callback function which will execute after response came from server.

    – Kanhaiya lal
    yesterday

















  • let me try this, come back to you

    – Muhammad Anas
    May 8 at 10:08











  • Don't think it is as easy :)

    – Muhammad Anas
    May 8 at 10:14











  • @MuhammadAnas Adding to the answer, Might be take as future reference, In javascript code is execute sequentially, or line by line so in after Ajax call, request sent to the server but it not guarantee that result will come before next line of code execute, so better to wait for dependent code (in your case slick), so need to add code in success callback function which will execute after response came from server.

    – Kanhaiya lal
    yesterday
















let me try this, come back to you

– Muhammad Anas
May 8 at 10:08





let me try this, come back to you

– Muhammad Anas
May 8 at 10:08













Don't think it is as easy :)

– Muhammad Anas
May 8 at 10:14





Don't think it is as easy :)

– Muhammad Anas
May 8 at 10:14













@MuhammadAnas Adding to the answer, Might be take as future reference, In javascript code is execute sequentially, or line by line so in after Ajax call, request sent to the server but it not guarantee that result will come before next line of code execute, so better to wait for dependent code (in your case slick), so need to add code in success callback function which will execute after response came from server.

– Kanhaiya lal
yesterday





@MuhammadAnas Adding to the answer, Might be take as future reference, In javascript code is execute sequentially, or line by line so in after Ajax call, request sent to the server but it not guarantee that result will come before next line of code execute, so better to wait for dependent code (in your case slick), so need to add code in success callback function which will execute after response came from server.

– Kanhaiya lal
yesterday













3














It's likely your AJAX request is completing AFTER the slider is initialised, see if adding your Slick JS to your success callback helps:



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();

jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);

);
);


If so I recommend you split your JS up into Require JS modules rather than inlining it inside a template then you can keep them separate and still call it in your success callback. I see JS inside PHTML as a bad practice, it makes maintenance much harder and I think it prevents your JS from being cached.






share|improve this answer























  • your answer is also correct but I can mark anyone answer correct. Still +1 for your effort. Thanks :)

    – Muhammad Anas
    May 8 at 10:13











  • You're welcome :D

    – Ben Crook
    May 8 at 10:18















3














It's likely your AJAX request is completing AFTER the slider is initialised, see if adding your Slick JS to your success callback helps:



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();

jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);

);
);


If so I recommend you split your JS up into Require JS modules rather than inlining it inside a template then you can keep them separate and still call it in your success callback. I see JS inside PHTML as a bad practice, it makes maintenance much harder and I think it prevents your JS from being cached.






share|improve this answer























  • your answer is also correct but I can mark anyone answer correct. Still +1 for your effort. Thanks :)

    – Muhammad Anas
    May 8 at 10:13











  • You're welcome :D

    – Ben Crook
    May 8 at 10:18













3












3








3







It's likely your AJAX request is completing AFTER the slider is initialised, see if adding your Slick JS to your success callback helps:



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();

jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);

);
);


If so I recommend you split your JS up into Require JS modules rather than inlining it inside a template then you can keep them separate and still call it in your success callback. I see JS inside PHTML as a bad practice, it makes maintenance much harder and I think it prevents your JS from being cached.






share|improve this answer













It's likely your AJAX request is completing AFTER the slider is initialised, see if adding your Slick JS to your success callback helps:



require([
'jquery'
], function($)
jQuery.ajax(
url: "/manufacturerpages/index/collection",
type: "POST",
data: "id= <?php echo $manpagedataarr['page_id']; ?>&categoryid=<?php echo $categoryid; ?>&carouselorder=<?php echo $manpagedataarr['carouselorder']; ?>&collection_type=<?php echo $manpagedataarr['collection_type']; ?>&product_ids=<?php echo $manpagedataarr['product_ids']; ?>&manufacturer=<?php echo $manpagedataarr['manufacturer']; ?>",
success: function (res)
//console.log(res);
var result = jQuery('.product-items', res).html();
var undefined = false;
if(typeof result === 'undefined')
result = res;
undefined = true;


jQuery(".featured-collector_<?php echo $categoryid; ?>").html(result);
jQuery(".landing-featured .ajax_loading").hide();
jQuery( "form[data-role='tocart-form']" ).catalogAddToCart();

jQuery('.featured-collector_<?php echo $categoryid; ?>').slick(
dots: false,
infinite: true,
slidesToShow: 6,
slidesToScroll: 2,
arrows: true,
autoplay: false,
draggable: true,
speed: 300
);

);
);


If so I recommend you split your JS up into Require JS modules rather than inlining it inside a template then you can keep them separate and still call it in your success callback. I see JS inside PHTML as a bad practice, it makes maintenance much harder and I think it prevents your JS from being cached.







share|improve this answer












share|improve this answer



share|improve this answer










answered May 8 at 10:05









Ben CrookBen Crook

9,4432578




9,4432578












  • your answer is also correct but I can mark anyone answer correct. Still +1 for your effort. Thanks :)

    – Muhammad Anas
    May 8 at 10:13











  • You're welcome :D

    – Ben Crook
    May 8 at 10:18

















  • your answer is also correct but I can mark anyone answer correct. Still +1 for your effort. Thanks :)

    – Muhammad Anas
    May 8 at 10:13











  • You're welcome :D

    – Ben Crook
    May 8 at 10:18
















your answer is also correct but I can mark anyone answer correct. Still +1 for your effort. Thanks :)

– Muhammad Anas
May 8 at 10:13





your answer is also correct but I can mark anyone answer correct. Still +1 for your effort. Thanks :)

– Muhammad Anas
May 8 at 10:13













You're welcome :D

– Ben Crook
May 8 at 10:18





You're welcome :D

– Ben Crook
May 8 at 10:18

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273822%2fmagento-2-slick-slider-function-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form