By ken nguyen on
Hi All,
I also create a popup form (I used bootstrap to do it). After I click the submit button - ajax will save the data to database successfully. (I did it successfully).
After that, I want to the popup close and the page reload (refesh). Any ideas for doing it?
Appreciate
Comments
You can use this method I
You can use this method I outline here to call a function after an ajax event: http://www.jaypan.com/tutorial/calling-function-after-ajax-event-drupal-7
You can pass your command as follows:
Then in your JS, you can set up the command as follows:
Contact me to contract me for D7 -> D10/11 migrations.
it didn't work
Hi Jaypan,
First of all, I say thanks with you.
I also following your instruction but it didn't work. Please help me to take a look on this. My code as below
file page_auto_reload.module
file page_auto_reload.js
You are declaring $form twice
You are declaring $form twice:
First:
$form is passed as an argument to your function here.
Then, you are attaching your JS to the $form variable here:
But right after that, you are overwriting your entire $form variable here:
So your JS is never attached. And you shouldn't declare the $form variable (in Drupal 7), as it is an argument that is passed to your function, so if it contains any code, you will overwrite it.
So to fix this, all you need to do is remove this line:
Contact me to contract me for D7 -> D10/11 migrations.
I try to delete $form = array(); but not work
Hi Jaypan,
You are right about $form = array(). However, after I delete the line $form = array(), the popup form still available after I press submit button. The page not reload. Please focus
$form['#prefix'] = 'Test'.
';
'
$form['#suffix'] = '
';
Are anything wrong with my code? Could you please give me your idea to fix
You'll need to do some
You'll need to do some debugging:
1) Is the .js file being attached?
2) Is your ajax callback function being called?
3) Is the prototype file in the .js file being called?
Contact me to contract me for D7 -> D10/11 migrations.
Thanks, I can do it successfully
Thanks, I can do it successfully
This works for me