I'm developing a module to integrate an external PHP framework which requires a recent version of jQuery. Instead of hard coding a specific jqmulti jQuery alias (e.g., jq171) it would be ideal to retrieve the alias from jqmulti so that if the alias format changes or if the jquery version specified in jqmulti changes the modules and themes using it will not break. Perhaps something like the following would work.

function jqmulti_jquery_alias($version = null, $exact = false) {
  // if $version is found then return that
  // else if not $exact and $version < alias version return that
}

Comments

goron’s picture

First, are you sure you need to use the alias? Remember you can always use the hooks to use the higher level jQuery with no need for the alias.

That said, I definitely agree that it makes sense to not require hard coding of the alias. Though I don't know if a php function is very useful, since the alias needs to be used in JS. It seems to me that jqmulti should either (a) load the alias name into the Drupal settings JS object, so that it can be accessed from nay script, or (b) just provide a version-agnostic alias, like jqmulti or jqm which would map to whatever version is being loaded.

Right now jqmulti only allows loading one extra jQuery library, so I don't think the $version and $exact functionality you suggest is required for now, if I understand it correctly.

tangent’s picture

I realized after playing with jqmulti that for a case like mine, where I am creating a module to support a 3rd party integrated framework with specific jQuery version requirements, that it is easier and makes more sense to load the additional jQuery version manually instead of depending on yet another module. If jqmulti supported many versions of jQuery at once that might give it value but only supporting a single version doesn't add any value for my use case.

goron’s picture

Title: Add api to retrieve one or more jquery aliases from jqmulti » Add version-independent alias
Issue summary: View changes

For now there should at least be a single alias like jqmulti.jQuery. This is enough since we only support one jQuery version. In the future there could be a function to get a list of aliases, but this is not necessary for now.

goron’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev