0

I want to ajaxify my site. Everything, that is usally parsed as "Page Content" sould be opened in a lightbox. So the idea is to ajaxify every link and let #lightbox be filled with the result.

but before ajax parses the request-result, I want some javascript to be done. So I want an event to be triggered after the ajax respond, and want to parse the result by myself.

any suggestions?

EDIT:

I could store the content in an hidden div#object, and use an ajax_command_invoke('body','trigger',array('myevent')) to trigger a function attached to myevent. Does this make sense? than I just dont know how to implement this to all links.

1

Are you using AJAX API? All the Ajax commands have the same return, for example

array(
    'command' => 'insert',
    'method' => 'html',
    'selector' => $selector,
    'data' => $html,
    'settings' => $settings,
);

And if you open the file misc/ajax.js, you will find insert() function in Drupal.ajax.prototype.commands. I think now you got the idea right? You just need to define a new ajax command by extending standard library, for example

Drupal.ajax.prototype.commands.lightbox = function (ajax, response, status) {
    // Do something with response.
};

And on server side, you just need to return

array(
    'command' => 'lightbox',
);

You can put more options in the command like what core does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.