Answers.Body: <p>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.</p>
  <p>I use 2s timeout, because <code>.on('crmFormSuccess', function(event, data) {});</code> did not work.</p>
  <p>This will works if you not open it from another popup.</p>
  <pre><code>CRM.loadForm(CRM.url('civicrm/contact/add', 'action=update&amp;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);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-22T16:09:02.870Z
Answers.LastActivityDate: 2022-03-22T16:09:02.870Z
Answers.UserDisplayName: vitius
Answers.Body: <p>I don't think loadForm is really what you want. You could just do it with regular jquery .get, e.g.</p>
  <pre><code>CRM.$.get('/civicrm/contribute/add?reset=1&amp;action=add&amp;context=standalone&amp;snippet=4',
    null,
    function(response) {
      CRM.$('#mything').html(response);
    }
  );
  </code></pre>
  <p>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.</p>
  <p>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:</p>
  <p><code>&lt;iframe src=&quot;/civicrm/contribute/add?reset=1&amp;action=add&amp;context=standalone&amp;snippet=4&quot;&gt;&lt;/iframe&gt;</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-21T18:03:00.523Z
Answers.Text: 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.
Answers.UserDisplayName: vitius
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-21T18:15:55.923Z
Answers.Text: 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.
Answers.UserDisplayName: vitius
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-21T17:40:54.587Z
Answers.LastActivityDate: 2022-03-21T17:40:54.587Z
Answers.UserDisplayName: Demerit
Body: <p>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 <em>mainTabContainer</em> div.</p>
  
Tags: <ajax><jquery><summaryfields><custom>
Title: CRM.loadForm into div without popup
ThreadText: # CRM.loadForm into div without popup
  
  (Asked by: username_0 on 2022-03-21)
  
  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.
  
  **Tags:** ajax, jquery, summaryfields, custom
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2022-03-22. Score: 1 | Accepted answer
  
  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);
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2022-03-21. Score: 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>`
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_0**: 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.  
  
  ---
  
  