Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Sticky div doesn't work after postback


Hi!
I'm using metronic v8 theme in my asp.net project (not mvc).
Generally js compenents stop working after postback on asp.net but i solve this calling them again after postback and they works. but on sticky divs doesn't work. I think I couldn't call them right way.

For example select2 dropdowns stop working after postback. and i call them like this and they works all time;


ScriptManager.RegisterStartupScript(this, GetType(), "x", "<script type = "text/javascript">$("#DrpPaymentTypes").select2();</script>", false);


or flatpickr


ScriptManager.RegisterStartupScript(this, GetType(), "x", "<script type = "text/javascript">$("#TxtInstallmentDate").flatpickr({format: "DD/MM/YYYY",minDate: "today",enableTime: false,parseDate: (datestr, format) => {return moment(datestr, format, true).toDate();}});</script>", false);


but sticky doesn't work. (data-kt-sticky-name="invoice")


ScriptManager.RegisterStartupScript(this, GetType(), "x", "<script type = "text/javascript">var stickyElement = document.querySelector("#invoice");
var sticky = new KTSticky(stickyElement);</script>", false);


or


ScriptManager.RegisterStartupScript(this, GetType(), "x", "<script type = "text/javascript">KTSticky.init();</script>", false);


could you offer a solution?
thank you


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 (3)


I tried but doesn't work.



Hi,

The initialization of KTComponents.init(); should trigger global KTSticky initialization. Please make sure that the initialization function has been triggered.

For more information about the KTSticky component, you can refer to <a href='https://preview.keenthemes.com/html/metronic/docs/general/sticky'>our KTSticky documentation</a>.

Regards,
Lauris Stepanovs,
Keenthemes Support Team



Hi,

Can you please try to call the global component init function after postback as explained here:


KTComponents.init();


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  :(