Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $99
Get for 99$

Reinit TinySlider after ajax update


Greetings! I'm having a hard time figuring this out with the KT integration. I have some cards loaded into a tiny slider. They scroll and everything works as expected, except data updated via ajax isn't displayed on the cards. The scrolling cards only show the dummy data from the initial page load. This makes sense, because that is what was on the cards when the tiny slider was initialized. How can I tell the tiny slider to re-initialize?

Cheers,

Ajar


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi,

Sorry for the late reply. Can you please do the following changes for a workaround:

1. Go to core/html/src/js/components/app.js and modify createTinySliders global TinySlider wrapper function as shown below:


var createTinySliders = function () {
if (typeof tns === "undefined") {
return;
}

// Sliders
const elements = Array.prototype.slice.call(document.querySelectorAll("[data-tns="true"]"), 0);

if (!elements && elements.length === 0) {
return;
}

elements.forEach(function (el) {
if (el.getAttribute("data-kt-initialized") === "1") {
return;
}

const obj = initTinySlider(el);
KTUtil.data(el).set("tns", tns);

el.setAttribute("data-kt-initialized", "1");
});
}


Then access to the slider via it's DOM object:


const sliderEl = document.querySelector("#my_slider");
const sliderObj = KTUtil.data(sliderEl).get("tns");
sliderObj.rebuild(); // update the slider


For more info please check the plugin's API docs here</a.

Then recompile your assets folder with <a href="https://preview.keenthemes.com/html/metronic/docs/getting-started/build/gulp">Gulp
or Webpack.

Please note that the build tools are required only in the development environment just to compile the assets when the source folder files are modified. In the hosting/server deployment, you will only need the compile assets, no need to install the build tools dependencies there.

Regards.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(