options: {
url: null,
block: true,
+ post: null,
crmForm: null
},
_originalContent: null,
} else {
url = url.replace(/snippet=[^&]*/, 'snippet=' + snippetType);
}
+ // See Civi\Angular\AngularLoader
+ if (snippetType === 'json' && CRM.angular) {
+ url += '&crmAngularModules=' + CRM.angular.modules.join();
+ }
}
return url;
},
return false;
});
},
+ _ajax: function(url) {
+ if (!this.options.post || !this.isOriginalUrl()) {
+ return $.getJSON(url);
+ }
+ return $.post({
+ url: url,
+ dataType: 'json',
+ data: this.options.post
+ });
+ },
refresh: function() {
- var that = this;
- var url = this._formatUrl(this.options.url, 'json');
+ var that = this,
+ hash = this.options.url.split('#')[1];
+ url = this._formatUrl(this.options.url, 'json');
+ $(this.element).data('urlHash', hash);
if (this.options.crmForm) $('form', this.element).ajaxFormUnbind();
if (this.options.block) this.element.block();
- $.getJSON(url, function(data) {
+ this._ajax(url).then(function(data) {
if (data.status === 'redirect') {
that.options.url = data.userContext;
return that.refresh();
$('[name="'+formElement+'"]', that.element).crmError(msg);
});
}
- }).fail(function(data, msg, status) {
+ }, function(data, msg, status) {
that._onFailure(data, status);
});
},