1

I create page where I want dynamically load different page into div. Jquery function CRM.loadForm dynamically load form, but it loads into popup. It is possible not create popup, but put the content to the div? Something like in contact summary page, when you click on relationship tab and it loads into mainTabContainer div.

2 Answers 2

1

In the end I use popup to copy content from it and put it to div and it works just fine. All javascript in form works.

I use 2s timeout, because .on('crmFormSuccess', function(event, data) {}); did not work.

This will works if you not open it from another popup.

CRM.loadForm(CRM.url('civicrm/contact/add', 'action=update&cid='+id));
$('.ui-dialog').hide();
$('.ui-widget-overlay').remove();
setTimeout(function(){
  $('#test').html($('.ui-dialog-content').get());
  $('.ui-dialog').remove();
  $('body').removeClass('ui-dialog-open');
}, 2000);
0

I don't think loadForm is really what you want. You could just do it with regular jquery .get, e.g.

CRM.$.get('/civicrm/contribute/add?reset=1&action=add&context=standalone&snippet=4',
  null,
  function(response) {
    CRM.$('#mything').html(response);
  }
);

Note the snippet=4 to strip off the CMS surrounding content, but you may need to add styling since it won't get the css.

Or if you have control over whether the target is a div or not and the url is for the same site, you can just use iframe instead:

<iframe src="/civicrm/contribute/add?reset=1&action=add&context=standalone&snippet=4"></iframe>

2
  • I tried something simillar: $.getJSON(url, function(data) { $("#test").html(data.content); }); But problem is that no javascript works. On your example datepicker, select contact and other dynamic functions not works. Iframe is solution, but its not perfect (need to at offset for each display size because top menu). On summary page it works somehow with method LoadPage, now I trying reverse engineering on this.
    – vitius
    Commented Mar 21, 2022 at 18:03
  • I can iframe whole page, not only snippet, but that is not perfect. I can also load it as popup and after get content from popup, put it to the div and remove popup via jquery. Or I can just figure out how it works on contact summary page which this solution I prefer.
    – vitius
    Commented Mar 21, 2022 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.