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?

execute a reload after a buttonpress in xcrud

mleij

New member
Joined
Dec 28, 2021
Messages
8
Reaction score
0
Points
1
Location
Leiden
I have the following function:

$xcrud_membership_events->button('#', 'Inschrijven Evenement', 'glyphicon glyphicon-pencil', 'xcrud-action',
array( // set action vars to the button
'data-task' => 'action',
'data-action' => 'signup',
'data-primary' => '{event_id}',
'data-confirm' => fetch_extended('Dashboard Signup'))
);

Would it be possible after the ajax script has executed to refresh/reload another xcrud dataset. Currently I have no way to control the script or have a return json after an Ajax function has been executed through a button press.

Hope someone can help.
 

DaDo

Administrator
Staff member
Joined
Dec 1, 2021
Messages
108
Reaction score
23
Points
18
I have the following function:

$xcrud_membership_events->button('#', 'Inschrijven Evenement', 'glyphicon glyphicon-pencil', 'xcrud-action',
array( // set action vars to the button
'data-task' => 'action',
'data-action' => 'signup',
'data-primary' => '{event_id}',
'data-confirm' => fetch_extended('Dashboard Signup'))
);

Would it be possible after the ajax script has executed to refresh/reload another xcrud dataset. Currently I have no way to control the script or have a return json after an Ajax function has been executed through a button press.

Hope someone can help.
try do this:
PHP:
$xcrud_membership_events->button('#', 'Inschrijven Evenement', 'glyphicon glyphicon-pencil', 'xcrud-action',
array(
    // ... other button options ...
    'id' => 'signup-button',
    'data-success' => 'reloadOtherXcrud' // Callback function name
)
);
And create new custom js function
Code:
function reloadOtherXcrud(response, container) {
    // Assicurati che l'azione sia quella corretta
    if (response.action === 'signup' && response.success === true) {
    // reload here
    }
}
 

mleij

New member
Joined
Dec 28, 2021
Messages
8
Reaction score
0
Points
1
Location
Leiden
This does not seem to trigger the javascript function:

PHP

$xcrud_membership_events->create_action('signup', 'dashboard_abo_signup_event');
$xcrud_membership_events->button('#', 'Signup Event', 'glyphicon glyphicon-pencil', 'xcrud-action',
array( // set action vars to the button
'data-task' => 'action',
'data-action' => 'signup',
'data-primary' => '{event_id}',
'data-confirm' => "Do you wish to sign up?",
'id' => 'signup-button',
'data-success' => 'reloadOtherXcrud' // Callback function name
)
);

Javascript
function reloadOtherXcrud(response, container) {
alert("Entering Function");
}

Do I miss something?
 
Top Bottom