xajax: confirmation message

by prettyscripts on 2008-02-19 15:49:20

javascriptajaxxajax

in v0.2.4, the command to display confirmation message is addConfirmCommands. in V0.5 it’s confirmCommands.

PHP:

$obj->ConfirmCommands(commandsmessage);

where commands is the number of response commands to skip if cancel is clicked from the confirmation dialog.

if not to continue to execute the rest of the function:

PHP:

function some_function() {
    $obj = new xajaxResponse();
    // some codes
    $continue 0;
    $obj->confirmCommands(1"Do you wish to continue");
    $continue 1// will not be skipped! see explanation below.
    if ($continue == 0)
        return $obj;
    // the rest of the codes
    return $obj;
}

this does not work. the confirm is done at the client side. the server sends the command in one go and doesn’t wait for the client’s response. (according to posts from xajax forums)

the best way to do it is to break up the function to smaller functions and call that function. ie move the codes you want to continue to another xajax function.

PHP:

function some_function() {
    $obj = new xajaxResponse();
    // some codes
    $obj->confirmCommands(1"Do you wish to continue");
    $obj->call("xajax_continue_function"); // this will be skipped
    return $obj;
}
function continue_function() {
    $obj = new xajaxResponse();
    // rest of code here
    return $obj;
}

an alternative way is to write a javascript to call the xajax function.

PHP:

<script type="text/javascript">
function js_confirm()
{
    var yes confirm('Do you wish to continue');
    if (yes)
        xajax_continue_function();
    else
        xajax_cancel_function();
}
</script>

Tags: confirm, javascript, xajax

2 comments

Comment by Cheap Wildcard SSL @ 2010-08-18 21:19:14
Wow, it worked! Again, thank xajax team a lot, especially easy to CTC (^_^)!
Comment by Joseba Koldo @ 2011-08-30 06:06:12
*****
Eskerrik asko, komandoak oso ondo lan egiten du !!

Leave a comment


Your email address will not be revealed on this site.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)