The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Hi,

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

  1. Go to <code>core/html/src/js/components/app.js</code> and modify <code>createTinySliders</code> global TinySlider wrapper function as shown below:
<pre> 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"); }); } </pre>

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

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

For more info please check the plugin's API docs <a href="https://github.com/ganlanyuan/tiny-slider">here</a.

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

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.