0

See this link : jQuery datepickers not initializing each time modal is loaded

I have exactly the same problem, given this solution, what Elements should I give these properties([data-toggle='open_modal']) on the page??

zari
  • 29
  • 1
  • 5
  • to element which triggers opening modal – ciekals11 Nov 25 '21 at 12:24
  • save This element causes me to open the modal. I put these properties, but it does not apply at all – zari Nov 25 '21 at 12:29
  • To have the problem described, you should already have a modal that opens automatically via bootstrap, most likely a `
    ` (note `-` not `_`). The solution the problem in your linked question is to add another toggle *to that same element* and have some code run on that new "toggle".
    – freedomn-m Nov 25 '21 at 12:37
  • 1
    TBH that's a slightly strange/obscure solution to the problem. If you're loading via ajax then you'll have a `success:` `.done()` callback - simply add the `.datepicker()` code into that callback (which the answer provides code for)- the `data-toggle=open_modal` seems like a red-herring. – freedomn-m Nov 25 '21 at 12:39
  • Re: comment above (please add details to your question via [edit], not in comments). It's not working because your button is added *after* the code in the linked answer `$("[data-toggle='open_modal']").click(function(event) {` runs - you need to use event delegation, change that to `$(document).on("click", "[data-toggle='open_modal']", function(event) {` – freedomn-m Nov 25 '21 at 12:52
  • My Code link:https://stackoverflow.com/questions/70095546/how-to-load-javascript-css-files-in-partial-view – zari Nov 25 '21 at 12:58

0 Answers0