info: Fix JavaScript to support older versions of CiviCRM and jQuery.
authorDavid Thompson <davet@gnu.org>
Wed, 5 Nov 2014 23:48:59 +0000 (18:48 -0500)
committerDavid Thompson <davet@gnu.org>
Wed, 5 Nov 2014 23:51:32 +0000 (18:51 -0500)
* 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

assets/js/member-info.js
templates/CRM/Memberdashboard/Page/Info.tpl

index 7158f054609600ef30adcde8846007be40ebbe5b..b4ff8d0857e64c16f770355f16bbaa15063b6a29 100644 (file)
@@ -19,9 +19,9 @@
  * <http://www.gnu.org/licenses/>.
  */
 
-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' + profile.attributes + '></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);
index cacca26f80a6d9b45f44cf48faaaf2ddeac54791..9382bffc29b1c875ce2a8a94e08a0b0bc7c29541 100644 (file)
@@ -29,3 +29,5 @@
 
 <div id="info-loading" class="blockUI blockOverlay" style="height:100px">
 </div>
+
+<div id="info-form"></div>