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) »
  • adding jquery on a custom field on the Advanced Search Page using drupal
Pages: [1]

Author Topic: adding jquery on a custom field on the Advanced Search Page using drupal  (Read 1118 times)

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
adding jquery on a custom field on the Advanced Search Page using drupal
March 16, 2011, 08:47:19 am
I have had success on adding some jquery to a custom data field that appears on Activity entering and editing data. But on advanced search I can not get my javascript to load after the Activity Accordion field is clicked and that area is expanded.

So far I have just done the standard civicrm procedure of using the TPL file in the source code, copying it to my drupal folder where I set civi templates to be. Then I added my script call out to the bottom of those pages. Works fine. But on this on the Advanced search page I am not having luck with the TPL file noted in search and as I try some other files like Activity.tpl or Advanced.tpl or AdvancedCriteria.tpl even though I get the script to load it just is loading. But I think cause the accordion effect introduces the html I am trying to hit with my code which was loaded before this but needs to be loaded after this.

Thanks

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: adding jquery on a custom field on the Advanced Search Page using drupal
March 16, 2011, 01:38:22 pm
Not sure exactly what is happening for you but another approach to geting JS on the page is in your Drupal theme or via a custom Drupal module. That actually avoids having to customize CiviCRM templates.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
Re: adding jquery on a custom field on the Advanced Search Page using drupal
March 16, 2011, 04:38:09 pm
Thanks for reply.
Yes I have tried that. Thing is, and I am not sure how well I can explain this since I am  not that clear on it, the Ajax that happens when you click the accordion fields in the advanced search calls in new classes and fields that are not there on the initial page load. And I am not sure how to cause my already loaded js effect those new elements.
I was able to do it in the edit add area cause
1. I told the accordion field to not collapse
2. I loaded the js after that area in the tpl file.

Thanks again for taking time to reply!

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: adding jquery on a custom field on the Advanced Search Page using drupal
March 17, 2011, 11:45:47 am
So you need either to put your JS in the loaded HTML or if you can find the JS that loads that HTML, it has a trigger you can use to run code AFTER that HTML loads.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
Re: adding jquery on a custom field on the Advanced Search Page using drupal
March 19, 2011, 06:18:02 am
solution so far.
I copied the Common.tpl file to my
customtemplates/CRM/Activity/Form/Search

The at line 102 I added
Code: [Select]
{literal}
<!--trying to get to this after some other scripts -->
<script type="text/javascript" src="/sites/all/modules/custom/customscript.js"></script>
{/literal}

before the end if statement.

That seems to be doing it.
Thanks for the feedback.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • adding jquery on a custom field on the Advanced Search Page using drupal

This forum was archived on 2017-11-26.