What's new

Welcome to xCrud Community - Data Management and extended PHP CRUD

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

action callback function.php (onclick=return confirm)

Bragg

New member
Joined
Jan 31, 2023
Messages
9
Reaction score
1
Points
3
Location
Deutschland
I am looking for a solution that only triggers the function in function.php if it has been confirmed by onclick.
Anyone an idea?

PHP:
$xcrud1->create_action('artikel_duplizieren', 'artikel_duplizieren'); // action callback, function  in functions.php

$xcrud1->button('#', 'Duplizieren', 'fa fa-plus', 'xcrud-action', array(

    'data-task' => 'action',

    'data-action' => 'artikel_duplizieren',

    'data-primary' => '{id_artikelstamm}',

    'onclick' => 'return confirm("Artikel {text} {artikelnr} jetzt duplizieren?")', // if true then do it

));
 
Last edited:

DaDo

Administrator
Staff member
Joined
Dec 1, 2021
Messages
104
Reaction score
18
Points
18
I am looking for a solution that only triggers the function in function.php if it has been confirmed by onclick.
Anyone an idea?

PHP:
$xcrud1->create_action('artikel_duplizieren', 'artikel_duplizieren'); // action callback, function  in functions.php

$xcrud1->button('#', 'Duplizieren', 'fa fa-plus', 'xcrud-action', array(

    'data-task' => 'action',

    'data-action' => 'artikel_duplizieren',

    'data-primary' => '{id_artikelstamm}',

    'onclick' => 'return confirm("Artikel {text} {artikelnr} jetzt duplizieren?")', // if true then do it

));
you have to use attribute function and call onclick from jQuery
 

DaDo

Administrator
Staff member
Joined
Dec 1, 2021
Messages
104
Reaction score
18
Points
18
could you show me an example pls.
YOU CAN SET PLUGIN ATTRIB YOU WANT TO DO

PHP:
$xcrud->set_attr('artikel_duplizieren',array('id'=>'artikel_duplizieren','data-text'=>'Are you sure you want to ....'));

JavaScript:
j(document).on("ready xcrudafterrequest", function(event, container,data) {

//here you can do all your request via javascript or jquery ajax
    
}
 

Bragg

New member
Joined
Jan 31, 2023
Messages
9
Reaction score
1
Points
3
Location
Deutschland
i don't think that helps me.
I have added a button in the table view, before this should be executed, there should be a confirmation message.
The confirm message comes, but when i click cancel, the function is still executed... :(
 

Bragg

New member
Joined
Jan 31, 2023
Messages
9
Reaction score
1
Points
3
Location
Deutschland
I found a solution.

Code:
$xcrud1->create_action('artikel_duplizieren', 'artikel_duplizieren'); // action callback, function publish_action() in functions.php
$xcrud1->button('#', 'Duplizieren', 'fa fa-plus', 'xcrud-action', array(
    'data-task' => 'action',
    'data-action' => 'artikel_duplizieren',
    'data-primary' => '{id_artikelstamm}',
    'data-confirm' => 'Artikel {text} {artikelnr} jetzt duplizieren?',
    'id' => 'artikel_duplizieren',
    'name' => 'artikel_duplizieren',
));

instead of
Code:
'onclick' => 'return confirm("Artikel {text} {artikelnr} jetzt duplizieren?")', // if true then do it
it works with
Code:
 'data-confirm' => 'Artikel {text} {artikelnr} jetzt duplizieren?',

Thanks for your help
 
Top Bottom