I have a node/add form that opens in a modal thickbox within a different node/add form. The ajax functionality works great. The form submits without refreshing the parent node/add form, which is what I need.
I'm not sure if I'm missing something, but I've been struggling for the last couple of days trying to close the modal thickbox on form submit. I added an onclick="tb_remove()" to the submit button which closes the thickbox, but of course closes it before validation, so if there are errors, the node isn't created. I've tried to implement client-side validation as well, but so far have been unsuccessful.
Do I need to create a ajax plugin for this functionality, or am I just missing something? I'm a relative js (and ajax) noob, so any input would be appreciated.

Thanks!

Comments

nlambert’s picture

I would love to know the same thing! :-)

Dinesh Kumar Sarangapani’s picture

Me too ;-)

Dinesh Kumar Sarangapani’s picture

I have added the javascript in ajax_thickbox.js based on the documentation given in http://drupal.org/node/349961

Drupal.Ajax.plugins.thickbox = function(hook, args) {
  var tb_init_original;
  if (hook === 'scrollFind') {
    if (args.container.id === 'TB_window') {
      return false;
    }
    else {
      return true;
    }
  }
  else if (hook === 'init') {
    tb_init_original = window.tb_init;
    window.tb_init = function(domChunk){
      tb_init_original(domChunk);
      Drupal.attachBehaviors($('#TB_window'));
    }
  }
  else if (hook === 'complete') {
    $('#TB_closeWindowButton').click()
    }
  return true;
}

But the hook is never called. It calls only init, submit, message.

am i missing something

brendoncrawford’s picture

Status: Active » Needs work