Reinit function for forms after reload them in a modal via A


Topic: Reinit function for forms after reload them in a modal via Ayax

h2-invent asked 5 years ago

Expected behavior When I load a form via Ayax into a modal then I expect that the form are working as normaly, so when I click them then the label should float

Actual behavior The Labels are not floating and are still over the text which can be typed into the formfield. In this constellation it is not usefull for us to work with the mdb unfortunentally. I need a reinit function which I can call to reinit material on the loaded form.

Resources (screenshots, code snippets etc.) enter image description here


Grzegorz Bujański staff commented 5 years ago

Hi. This happened because change value using JS does not trigger any events. Try trigger change event after load value via Ajax.

Best, Grzegorz.


h2-invent commented 5 years ago

Hello Grzegorz, this is my code, with it I reload the form into the modal.Where can I make your changes? $(document).on('click', '.loadContent', function (e) { e.preventDefault(); var url = $(this).attr('href'); $('#loadContentModal').load(url, function () { $('#loadContentModal').modal('show');

$('select').materialSelect();});});


Grzegorz Bujański staff commented 5 years ago

Try before $('#loadContentModal').modal('show'); Best, Grzegorz.


h2-invent commented 5 years ago

Hello, sorry for the unprecise question, what it the element and the function I should trigger the change event.

Best regards


Grzegorz Bujański staff commented 5 years ago

you should use something like `$('input').trigger('change')'; in your code. Look at here: https://api.jquery.com/trigger/


h2-invent commented 5 years ago

thank Grzegorz, it works now. the problem was a wron initilisation of MDB because it is not in my Webpack. The idea to trigger the checge worked perfectly. But now I have new problem with the select Dropdown in the same modal, I will post it in a separtate post.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.14.1
  • Device: ALl
  • Browser: All
  • OS: Windows
  • Provided sample code: No
  • Provided link: No