From: David Thompson Date: Wed, 5 Nov 2014 23:48:59 +0000 (-0500) Subject: info: Fix JavaScript to support older versions of CiviCRM and jQuery. X-Git-Tag: v0.1~28 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5bf8e4994f39271db0ba90f424143ff8d0ca0a8c;p=org.fsf.memberdashboard.git info: Fix JavaScript to support older versions of CiviCRM and jQuery. * assets/js/member-info.js: Fall back to using 'jQuery' instead of 'CRM.$'. Parse profile JSON if it hasn't already been parsed. * templates/CRM/Memberdashboard/Page/Info.tpl --- diff --git a/assets/js/member-info.js b/assets/js/member-info.js index 7158f05..b4ff8d0 100644 --- a/assets/js/member-info.js +++ b/assets/js/member-info.js @@ -19,9 +19,9 @@ * . */ -CRM.$(function($) { +(function($) { function loadProfile(gid, success) { - $.get('/drupal/civicrm/profile/edit', { + $.get('/civicrm/profile/edit', { gid: gid, json: 1 }, success); @@ -42,6 +42,9 @@ CRM.$(function($) { .value(); } + // Support older versions of jQuery that don't parse the JSON by + // default. + profile = _.isString(profile) ? JSON.parse(profile): profile; var form = $(''); form.append(profile.requirednote) @@ -49,10 +52,10 @@ CRM.$(function($) { .append.apply(form, renderFields()); $('#info-loading').remove(); - $('#crm-main-content-wrapper').append(form); + $('#info-form').append(form); } $(document).ready(function() { loadProfile(memberDashboard.profileId, renderProfile); }); -}); +})(jQuery); diff --git a/templates/CRM/Memberdashboard/Page/Info.tpl b/templates/CRM/Memberdashboard/Page/Info.tpl index cacca26..9382bff 100644 --- a/templates/CRM/Memberdashboard/Page/Info.tpl +++ b/templates/CRM/Memberdashboard/Page/Info.tpl @@ -29,3 +29,5 @@
+ +