Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Conversation

jamsilver
Copy link
Contributor

So basically this adds the gubbins for making custom Ajax requests to the server from javascript without particularly being in the context of a DOM element in the way Drupal.ajax assumes.

It also adds the server-side gubbins for specifying what should happen on this ajax request and what ajax commands should be returned.

See the PHPDoc at the top of includes/ajax_operations.inc for full details of how it all works.

The use case I am in which is using this is:

  1. We have been provided with a flatbuild which has a custom jQueryUI tabs widget, it does an ajax request to get the contents of the request.
  2. By swapping out it's call to jQuery.ajax() with CMToolsAjaxOperation() we get a couple of important bits of functionality for free that come with the Drupal Ajax framework:
    • Auto-loading of any extra CSS and Javascript needed to display the tab not already on the page (very important)
    • The ability to communicate in ajax commands - e.g. allowing arbitrary other functionality to be added/altered onto the ajax response
  3. Through judicious use of the direct callback functionality/command which CMToolsAjaxOperation supports it wasn't even that difficult to swap out the call to jQuery.ajax() with Drupal.CMToolsAjaxOperation!!

@@ -0,0 +1,648 @@
From e40b42b13d303b0a6fa281b017755efc1104526a Mon Sep 17 00:00:00 2001
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamsilver Why is there a patch file in the change request?

@@ -0,0 +1,136 @@
(function($) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamsilver Can you provide a minified version of this javascript for inclusion in production?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't make this a library / with minified options etc simply because I was following ctool's model (as the cm_tools module has been doing). Does it matter that much?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're better than ctools :)

Yeah, we should do this all proper like, with minified versions and hook_library implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minified options++ Front end perf is by and large lots of small cumulative wins.

On Thursday, 8 August 2013 at 12:05, James Silver wrote:

In js/ajax-operations.js:

@@ -0,0 +1,136 @@ > +(function($) {
I didn't make this a library / with minified options etc simply because I was following ctool's model (as the cm_tools module has been doing). Does it matter that much?


Reply to this email directly or view it on GitHub (https://github.com/computerminds/cm_tools/pull/12/files#r5654917).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants