Question

$(".bilgi4").editable("'.site_url().'kullanici/guncelle/sifre", { 
                onsubmit: function() {
                jConfirm("Şifrenizi değiştirmek istiyor musunuz?", "Onay", function(r) { 
                    return r;   
                }); 
                },
                indicator : '<img src="'.base_url().'tema/site/images/loading.gif" />',
                type      : 'text',
                cancel    : '<div class="iptalbuton2"></div>',                
                submit    : '<div class="kaydetbuton"></div>',
            });

When i click submit button confirmation dialog opening but before i answer the question form post itself.

Was it helpful?

Solution

I assume jConfirm is non-blocking and onsubmit continues execution after that line. So you will need to return false in the handler to stop submitting, and manually submit the form yourself depending on whether the user confirmed or not. Also you will need to disable cancellation when onblur event fires.

$(".bilgi4").editable("http://google.com", {
    onsubmit: function(settings, ele) {
        var confirmed = $(ele).data('editConfirmed');
        $(ele).data('editConfirmed', false);

        if (! confirmed) {
            jConfirm('Title', 'Are you sure?', function(r) {
                if (r) {
                    $(ele).data('editConfirmed', true);
                    $(ele).find('form:eq(0)').submit();
                } else {
                    $(ele).data('editConfirmed', false);
                }
            });
        }

        return confirmed === true;
    },
    onblur    : 'ignore',
    type      : 'text',
    cancel    : '<div class="iptalbuton2">Cancel</div>',
    submit    : '<div class="kaydetbuton">Submit</div>',
});

See http://jsfiddle.net/NA495/ for a little demo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top