question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

leanModal() - complete and ready callbacks are not executed

See original GitHub issue

Here is the code to initialize Modal (on element ID):

$('#modal_confirm').leanModal({
        dismissible: false,
        out_duration: 200,
        complete: function() { console.log('closed'); },
        ready: function() { console.log('open'); }
    });

The modal itself:

<div id="modal_confirm" class="modal">
    <div class="modal-content" id="modal_confirm_content"></div>
    <div class="modal-footer">
        <a id="modal_confirm_action_yes" href="#" class="modal-action modal-close waves-effect waves-green btn green">Yes</a>
        <a href="#" class="modal-action modal-close waves-effect waves-red btn red">No</a>
    </div>
</div>

The modal is opened using openModal() function, since it also automatically fills down contents and assigns additional callback function to “yes” button - here is the function:

function showConfirmation(confirmText, positiveCallbackFunction) {
    $('#modal_confirm_content').html(confirmText);
    $('#modal_confirm').openModal();
    $('#modal_confirm_action_yes').on('click', function() {
        positiveCallbackFunction();
    });
}

Generally as it is now the “closed” or “open” texts never appears on console. The version of Materialize used is 0.97.7 pulled from cdnjs.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

3reactions
acburstcommented, Aug 13, 2016

Yes currently there are a lot of problems with our modal plugin. Currently using the openModal method does not use any of the options you defined. For a temporary fix you can store your options in a variable and pass that in to both .leanModal(options) and .openModal(options)

I’m currently working on rewriting the modal plugin to look similar to our other plugins where you would do things like .leanModal('open') instead of calling openModal

0reactions
nickgomez19commented, Jul 9, 2017

Even on .99 .modal(‘open’) does not trigger ready or complete (or creates a new modal, replacing the old one, I can’t tell). You have to trigger the button or elements that correspond.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Materialize Cssmodal showing $(..)leanmodal is not a function ...
When I try to create a a materialize css moal using the below code , I am getting Error. <script src="~/Scripts/jquery ...
Read more >
Dogfalo/materialize - Gitter
leanModal ( { ready: function() { // Callback for Modal open. ... @Dogfalo please fix materializecss.com/dropdown.html it's not working. 2cbb051a.
Read more >
Modals - Materialize
Introduction. Use a modal for dialog boxes, confirmation messages, or other content that can be called up. In order for the modal to...
Read more >
Modals - Materialize
For example, you can call a custom function to run when a modal is ... onOpenStart, Function, null, Callback function called before modal...
Read more >
leanModal - a JQuery modal plugin that works with your CSS
Weaknesses. no gallery, iframe or ajax support; untested in IE6. Examples: Basic | With Close Button.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found