CRM-13863 - Only load real links not js buttons
[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 .on('click', 'a.button, a.action-item', function() {
9 // only follow real links not javascript buttons
10 if ($(this).attr('href') === '#' || $(this).attr('onclick')) {console.log('bogus', this);
11 return;
12 }
13 CRM.loadForm($(this).attr('href'), {
14 openInline: 'a:not([href="#"])'
15 }).on('crmFormSuccess', function(e, data) {
16 // Refresh page when form completes
17 $('#crm-main-content-wrapper').crmSnippet('refresh');
18 });
19 return false;
20 });
21 });