Merge pull request #2318 from kenahoo/patch-1
[civicrm-core.git] / js / crm.livePage.js
1 // http://civicrm.org/licensing
2 // Adds ajaxy behavior to a simple CiviCRM page
3 cj(function($) {
4 $('#crm-main-content-wrapper')
5 // Widgetize the content area
6 .crmSnippet()
7 // Open action links in a popup
8 .off('click.crmLivePage')
9 .on('click.crmLivePage', 'a.button, a.action-item', function() {
10 var url = $(this).attr('href');
11 // only follow real links not javascript buttons
12 if (url === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) {
13 return;
14 }
15 CRM.loadForm(url, {
16 openInline: 'a:not("[href=#], .no-popup")'
17 }).on('crmFormSuccess', function(e, data) {
18 // Refresh page when form completes
19 $('#crm-main-content-wrapper').crmSnippet('refresh');
20 });
21 return false;
22 });
23 });