AdminLTE startup crash / event listener

Bootstrap has convenient events that fire when the .collapse classes are used properly. When using AdminLTE expandable boxes, I was hoping I could do something similar so that I could deactivate the rendering inside the box when it is fully collapsed and reactivate the rendering when it is fully open.

I tried using events from here , for example, show.bs.collapse or hidden.bs.collapse, following their example:

$('#myCollapsible').on('hidden.bs.collapse', function () {
    // do something…
})

But after entering this event, it seems that the AdminLTE precast blocks do not fire these events. I searched to see if there are similar events for the AdminLTE plug-in, but it does not seem to exist. I also looked to see if I could make a listener when the flattened box class is added to the div in question, but this is not an option, as solutions assume you release this event yourself. Unfortunately, I do not control when the class is added.

Does anyone have a solution? Thanks in advance!

+4
source share
3 answers

admin.ltE app.js . , addClass removeClass, (slideUp) (slideDown), .

box_content.slideUp(_this.animationSpeed, function () {
    box.addClass("collapsed-box");
    box.trigger('collapsed',[box, element]);
});

box_content.slideDown(_this.animationSpeed, function () {
    box.removeClass("collapsed-box");
    box.trigger('expanded',[box, element]);
});
+2

.

:

$(seletor).on("remove", function (){ //code here })

.

, "click" :

$("#boxdiv button").on("click", function () {
   // Close event
})

.

+1

app.js ( bower), :

$("#my-box-id [data-widget='collapse']").click(function() {
    var box = $(this).parents(".box").first();
    if (!box.hasClass("collapsed-box")) {
        console.log("collapsing #my-box-id ...");
    } else {
        console.log("expanding #my-box-id ...");
    }
});
0

Source: https://habr.com/ru/post/1648028/


All Articles