CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Livequery from Drupal
Pages: [1]

Author Topic: Livequery from Drupal  (Read 1163 times)

jakecivi

  • I post frequently
  • ***
  • Posts: 140
  • Karma: 0
Livequery from Drupal
April 19, 2012, 03:48:23 pm
I wonder, in pages like the Configure Event -> Fee tab, where Civi loads the contents of the tabbed page area after the page itself, and therefore after any javascript added by drupal_add_js runs, how do I change things loaded in the tabbed area? I'm loading a copy of livequery from my module's folder with drupal_add_js, but then I don't know where to go from there, because neither accessing civicrm's copy of jquery like cj('#selector').livequery(function() {....}); nor accessing Drupal's copy of jquery like $('#selector').livequery(function() {....}); has any effect. Anyone know where to go from here?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Livequery from Drupal
April 20, 2012, 08:53:16 am
I'd start with the buildForm hook (http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviCRM+hook+specification) and try to include the js in there. Not sure if drupal_add_js will work at that point in the chain but you could insert a <script> tag manually.
If that doesn't work you could edit the tpl file for the tab to include your js.

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Livequery from Drupal
April 20, 2012, 08:56:58 am
Or if you want it on every page might be simpler to edit templates/CRM/common/jquery.tpl and jquery.files.tpl

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Livequery from Drupal
April 20, 2012, 02:45:31 pm
is the livequery existing and the init code run before the dom exists?

You might want to delay where the init code is loaded (eg. on the load instead of the ready event) or wait on an event that is linked to the content you want to alter (with the .on method, you can watch more or less everything, including inserting elements in the dom)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jakecivi

  • I post frequently
  • ***
  • Posts: 140
  • Karma: 0
Re: Livequery from Drupal
April 23, 2012, 06:26:28 am
Ah.  Okay, thanks.  Will try.  It would be really nice to not have to require installing custom templates in order to use my module.

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Livequery from Drupal
April 23, 2012, 02:18:30 pm
You don't have to. You can use the buildForm hook (in your module). Or now that I think of it drupal's hook_init might be better.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Livequery from Drupal

This forum was archived on 2017-11-26.