Uikit: Event handler for alert, confirm, prompt

Created on 9 Sep 2015  路  1Comment  路  Source: uikit/uikit

Is it possible add event handler for dynamic modal (alert, confirm, prompt)?

Most helpful comment

i found solution:
please update from this:

UI.modal.alert = function(content, options) {
    UI.modal.dialog(([
        '<a class="uk-close uk-modal-close"></a>',
        '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
        '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">Ok</button></div>'
    ]).join(""), UI.$.extend({bgclose:false, keyboard:false}, options)).show();
};

to this:

UI.modal.alert = function(content, options) {
    var modal = UI.modal.dialog(([
        '<a class="uk-close uk-modal-close"></a>',
        '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
        '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">Ok</button></div>'
    ]).join(""), UI.$.extend({bgclose:false, keyboard:false}, options)).show();
    return modal;
};

and was possible use closure:

UIkit.modal.alert("your text", {center: true}).on('hide.uk.modal', function() {
    // custome js code
});

>All comments

i found solution:
please update from this:

UI.modal.alert = function(content, options) {
    UI.modal.dialog(([
        '<a class="uk-close uk-modal-close"></a>',
        '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
        '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">Ok</button></div>'
    ]).join(""), UI.$.extend({bgclose:false, keyboard:false}, options)).show();
};

to this:

UI.modal.alert = function(content, options) {
    var modal = UI.modal.dialog(([
        '<a class="uk-close uk-modal-close"></a>',
        '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
        '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">Ok</button></div>'
    ]).join(""), UI.$.extend({bgclose:false, keyboard:false}, options)).show();
    return modal;
};

and was possible use closure:

UIkit.modal.alert("your text", {center: true}).on('hide.uk.modal', function() {
    // custome js code
});

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peturh picture peturh  路  3Comments

papazetis picture papazetis  路  3Comments

drmzio picture drmzio  路  3Comments

eric-22 picture eric-22  路  3Comments

collegeimprovements picture collegeimprovements  路  3Comments