Materialize: Callback for dismissable collection item

Created on 2 Mar 2015  路  6Comments  路  Source: Dogfalo/materialize

Is there a callback to get the dismissed element ?

Collection enhancement has-pr js

Most helpful comment

Hey everyone! I found this workaround and using it for the time being. I'm posting this for others that need this hack. I found this in StackOverflow..here's the link http://stackoverflow.com/questions/2200494/jquery-trigger-event-when-an-element-is-removed-from-the-dom

I love this framework..I'll definitely donate when I sold my first app using Materializecss..Keep it up!

(function() {
    var ev = new $.Event('remove'),
        orig = $.fn.remove;
    $.fn.remove = function() {
        $(this).trigger(ev);
        return orig.apply(this, arguments);
    }
})();

$('.dismissable').bind('remove', function() {
    console.log('removed!');
    // do pre-mortem stuff here
    // 'this' is still a reference to the element, before removing it
});

All 6 comments

How would you want this callback to be structured?

Hi! do we have this callback for dismissable collection. Like when i dismiss an item..i can call my function to also delete that item in my database.. thanks

Hey everyone! I found this workaround and using it for the time being. I'm posting this for others that need this hack. I found this in StackOverflow..here's the link http://stackoverflow.com/questions/2200494/jquery-trigger-event-when-an-element-is-removed-from-the-dom

I love this framework..I'll definitely donate when I sold my first app using Materializecss..Keep it up!

(function() {
    var ev = new $.Event('remove'),
        orig = $.fn.remove;
    $.fn.remove = function() {
        $(this).trigger(ev);
        return orig.apply(this, arguments);
    }
})();

$('.dismissable').bind('remove', function() {
    console.log('removed!');
    // do pre-mortem stuff here
    // 'this' is still a reference to the element, before removing it
});

Thanks for the workaround.

It would be fantastic, if materialize could provide us with a callback. I'd need to know the element that has been swiped and the direction (left or right), so I can trigger a different action accordingly. An example would be an email inbox, where swiping left could trigger a delete, while swiping right could trigger a "remind me later" action. In both cases would the visual list item be removed from the DOM afterwards.

transitions.js has been removed for 1.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MickaelH974 picture MickaelH974  路  3Comments

djensen47 picture djensen47  路  3Comments

ruslandzhumaev picture ruslandzhumaev  路  3Comments

bradley-varol picture bradley-varol  路  3Comments

ReiiYuki picture ReiiYuki  路  3Comments