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) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Adding JQuery in Membership Form
Pages: [1]

Author Topic: Adding JQuery in Membership Form  (Read 753 times)

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Adding JQuery in Membership Form
May 23, 2012, 06:31:17 am
hey guys,

I want to add some JQuery script when a user changes the selected option in a custom field, in the Membership create / edit form.

I want to use the TEMPLATE.extra.tpl feature, but I cannot find which template I have to create the extra file.
I've added the custom template Member/Form/Membership.extra.tpl (I guessed that was the right one) but the JS script is never executed.

Any idea which is the right template name I should create  for this?

cheers

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: Adding JQuery in Membership Form
June 14, 2012, 07:39:03 am
on this page http://wiki.civicrm.org/confluence/display/CRMDOC40/Customize+Built-in%2C+Profile%2C+Contribution+and+Event+Registration+Screens

under 'reate a Custom Screen' that's how you find which tpl file you need (also make sure you set up your directories). then just create the extra tpl for that same file.

clear your caches as well so that it finds the new files.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Adding JQuery in Membership Form
June 23, 2012, 03:14:10 pm
Two common errors I made:

1) be sure the path of your custom template is set up properly in the admin screen
2) be sure you put {literal}<script> around your js code and if you do jquery, you need to use the one from civicrm, not the one from your theme/drupal:

.extra.tpl
Code: [Select]
<script>
{literal}
cj(function ($) {
  $("...")...; // do your normal jquery code
});
{/literal}
</script>
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Adding JQuery in Membership Form

This forum was archived on 2017-11-26.