Set a class to the Editor Modal or attach it to a specific container

Set a class to the Editor Modal or attach it to a specific container

sdroulerssdroulers Posts: 43Questions: 14Answers: 0

Hi,

I have been through the forum for an answer and found some interesting infos.

In my project I need to edit the modal generated by the Editor. Actually when it pops up it is attached directly to the body of my document. If I change any setting directly on this modal it will affect others and this I don't want.

Therefore I look for a way to add a class to it / attach it to a specific container when it opens.

I've read this very interesting post :
https://datatables.net//forums/discussion/comment/93649/#Comment_93649

and found out about this :

$.fn.DataTable.Editor.display.bootstrap._dom.content

So far the first solution doesn't really fit, I have plenty of tables and just want to edit the modal of a specific one.

For the second, I confess I have no idea if I can do what I want with it.

By advance many thanks for your ideas,

Sébastien

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    $.fn.DataTable.Editor.display.bootstrap.node() will give you the modal node - so you could use:

    $( $.fn.DataTable.Editor.display.bootstrap.node() ).addClass( 'myClass' );
    

    This is assuming you are using Bootstrap styling.

    Allan

  • sdroulerssdroulers Posts: 43Questions: 14Answers: 0

    Thumbs up! Many thanks Allan!

  • admin_atyantikadmin_atyantik Posts: 2Questions: 0Answers: 0

    Usage of $.fn.DataTable.Editor.display.bootstrap.node() throws error in version 1.9.1 editor.bootstrap4.min.js

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @admin_atyantik ,

    I'm seeing that too! I've raised it internally (DD-1187 for my reference) and we'll report back here when there's an update.

    Cheers,

    Colin

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi @admin_atyantik,

    Thanks for noting that. This change comes from the fact that there is now a Bootstrap model per Editor instance. So what you need to do is pass the Editor instance into the node() function - e.g.:

    $.fn.DataTable.Editor.display.bootstrap.node(editor)
    

    And that will give you the node for that specific instance of Editor.

    Regards,
    Allan

  • admin_atyantikadmin_atyantik Posts: 2Questions: 0Answers: 0

    Ah I see. Thank you, I'll update my workaround with this update.

This discussion has been closed.