Drupal: How do I modify form ui after 'Remove' button pressed using AJAX? -


i using drupal 6 , have ajax module installed. have following code:

function remove_manufacturer_role_form($form_state) {   $form['#ajax'] = array(     'enabled' => true   );   $form['hidden'] = array('#type' => 'value', '#value' => 'is_it_here');   $form['submit'] = array('#type' => 'submit', '#value' => t('remove manufacturer'));   return $form; }  function remove_manufacturer_role_form_submit($form, &$form_state) {      $current_vars = ogrolerequestmanufacturerblock_get_current_vars();       if( $current_vars )      {     $curr_gid = $current_vars['current_gid'];     $curr_uid = $current_vars['current_user_id'];     $delete_query = "delete {og_users_roles} rid in (select rid {role} name='manufacturer') , uid=$curr_uid , gid=$curr_gid";     if( db_query($delete_query) )         drupal_set_message("you removed manufacturer project");      } } 

basically, have form remove user manufacturer within project. user has ability remove themselves. form allows user click button, in turn uses ajax submit form, delete user's role manufacturer database, , notify user whether successful or not. makes call using ajax , deletes role should, form still has remove button shown on it. if user clicks button again gives error b/c there nothing delete. ok, guess, b/c not fatal error , doesn't affect ... however, it's not pretty user.

is there way can refresh module's block or modify form shown once submitted?

edit:

this seems solution, can't quite seem working. i've included delete.js javascript within module:

/**  * ajax forms plugin ogrolerequestmanufacturerblock   *  * @param {string} hook  * @param {object} args  * @return {bool}  */  drupal.ajax.plugins.ogrolerequestmanufacturerblock = function(hook, args) { alert('it got javascript!');     if (hook === 'submit') {         alert('submit called within javascript!');     }     return true; } 

it never seems javascript function. how drupal know call specific function?

you can check return value coming through ajax , if removal has been successful, can display: none on remove button.

looking @ ajax module documentation, think need implement drupal.ajax.plugins.foo(hook, args). when hook == complete, can set button display: none.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -