title: Uncaught Error: cannot call methods on dialog prior to initialization using jQuery
body: <p>When a user clicks on a link, I want to populate a modal dialog and show it. So I am populating this model dialog with the response of a GET method, using AJAX, like the following:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;a data-rec="@Model.rec" data-seg="@Model.seg" data-det="@Model.seg" class="btn btn-default checkRulesLink"&gt;Check Rules&lt;/a&gt;
  &lt;div id="dialog-rules" title="Rules" class="dialog"&gt;
  &lt;/div&gt;    
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>$("#dialog-rules").dialog({
    autoOpen: false,
    modal: true,
    title: "Details",
    buttons: {
      Close: function() {
        $(this).dialog('close');
      }
    }
  });
  
  $(".checkRulesLink").click(function(e) {
    $("#dialog-rules").html("");
    e.preventDefault();
    var rec = $(this).data('rec');
    var seg = $(this).data('seg');
    var det = $(this).data('det');
    $.ajax({
      url: "/Booking/CheckRules?rec=" + rec + "&amp;seg=" + seg + "&amp;det=" + det,
      success: function(result) {
        console.log(result);
        $("#dialog-rules").html(result);
        $("#dialog-rules").dialog("open");
      }
    });
  });
  </code></pre>
  
  <p>The AJAX call works fine, but whenever I click on the link, I get this error:</p>
  
  <pre><code>Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'open'
      at Function.error (VM32 jquery-1.12.4.js:253)
      at HTMLDivElement.&lt;anonymous&gt; (VM33 jquery-ui.js:246)
      at Function.each (VM32 jquery-1.12.4.js:370)
      at jQuery.fn.init.each (VM32 jquery-1.12.4.js:137)
      at jQuery.fn.init.$.fn.(anonymous function) [as dialog] (https://code.jquery.com/ui/1.12.1/jquery-ui.js:236:10)
      at Object.success (Flights:18216)
      at fire (VM32 jquery-1.12.4.js:3232)
      at Object.fireWith [as resolveWith] (VM32 jquery-1.12.4.js:3362)
      at done (VM32 jquery-1.12.4.js:9840)
      at XMLHttpRequest.callback (VM32 jquery-1.12.4.js:10311)
  error @ VM32 jquery-1.12.4.js:253
  (anonymous) @ VM33 jquery-ui.js:246
  each @ VM32 jquery-1.12.4.js:370
  each @ VM32 jquery-1.12.4.js:137
  $.fn.(anonymous function) @ VM33 jquery-ui.js:236
  success @ Flights:18216
  fire @ VM32 jquery-1.12.4.js:3232
  fireWith @ VM32 jquery-1.12.4.js:3362
  done @ VM32 jquery-1.12.4.js:9840
  callback @ VM32 jquery-1.12.4.js:10311
  XMLHttpRequest.send (async)
  send @ VM32 jquery-1.12.4.js:10254
  ajax @ VM32 jquery-1.12.4.js:9738
  (anonymous) @ Flights:18211
  dispatch @ VM32 jquery-1.12.4.js:5226
  elemData.handle @ VM32 jquery-1.12.4.js:4878
  2VM95:46 Uncaught TypeError: jQuery.easing[jQuery.easing.def] is not a function
      at Object.swing (eval at &lt;anonymous&gt; (VM32 jquery-1.12.4.js:349), &lt;anonymous&gt;:46:42)
      at init.run (VM32 jquery-1.12.4.js:7402)
      at tick (VM32 jquery-1.12.4.js:7747)
      at jQuery.fx.tick (VM32 jquery-1.12.4.js:8069)
  swing @ VM95:46
  run @ VM32 jquery-1.12.4.js:7402
  tick @ VM32 jquery-1.12.4.js:7747
  jQuery.fx.tick @ VM32 jquery-1.12.4.js:8069
  setInterval (async)
  jQuery.fx.start @ VM32 jquery-1.12.4.js:8093
  jQuery.fx.timer @ VM32 jquery-1.12.4.js:8083
  Animation @ VM32 jquery-1.12.4.js:7823
  doAnimation @ VM32 jquery-1.12.4.js:7926
  dequeue @ VM32 jquery-1.12.4.js:4157
  (anonymous) @ VM32 jquery-1.12.4.js:4201
  each @ VM32 jquery-1.12.4.js:370
  each @ VM32 jquery-1.12.4.js:137
  queue @ VM32 jquery-1.12.4.js:4194
  animate @ VM32 jquery-1.12.4.js:7937
  jQuery.fn.(anonymous function) @ VM32 jquery-1.12.4.js:8053
  (anonymous) @ VM83:24
  fire @ VM32 jquery-1.12.4.js:3232
  add @ VM32 jquery-1.12.4.js:3291
  jQuery.fn.ready @ VM32 jquery-1.12.4.js:3542
  (anonymous) @ VM83:1
  (anonymous) @ VM32 jquery-1.12.4.js:349
  globalEval @ VM32 jquery-1.12.4.js:350
  text script @ VM32 jquery-1.12.4.js:10372
  ajaxConvert @ VM32 jquery-1.12.4.js:9332
  done @ VM32 jquery-1.12.4.js:9789
  callback @ VM32 jquery-1.12.4.js:10311
  send @ VM32 jquery-1.12.4.js:10321
  ajax @ VM32 jquery-1.12.4.js:9738
  jQuery._evalUrl @ VM32 jquery-1.12.4.js:9902
  domManip @ VM32 jquery-1.12.4.js:6086
  append @ VM32 jquery-1.12.4.js:6269
  (anonymous) @ VM32 jquery-1.12.4.js:6375
  access @ VM32 jquery-1.12.4.js:4399
  html @ VM32 jquery-1.12.4.js:6338
  success @ Flights:18215
  fire @ VM32 jquery-1.12.4.js:3232
  fireWith @ VM32 jquery-1.12.4.js:3362
  done @ VM32 jquery-1.12.4.js:9840
  callback @ VM32 jquery-1.12.4.js:10311
  XMLHttpRequest.send (async)
  send @ VM32 jquery-1.12.4.js:10254
  ajax @ VM32 jquery-1.12.4.js:9738
  (anonymous) @ Flights:18211
  dispatch @ VM32 jquery-1.12.4.js:5226
  elemData.handle @ VM32 jquery-1.12.4.js:4878
  js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:95 You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors.
  Hg @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:95
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:158
  google.maps.Load @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:18
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:158
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:159
  373VM95:46 Uncaught TypeError: jQuery.easing[jQuery.easing.def] is not a function
      at Object.swing (eval at &lt;anonymous&gt; (VM32 jquery-1.12.4.js:349), &lt;anonymous&gt;:46:42)
      at init.run (VM32 jquery-1.12.4.js:7402)
      at tick (VM32 jquery-1.12.4.js:7747)
      at jQuery.fx.tick (VM32 jquery-1.12.4.js:8069)
  swing @ VM95:46
  run @ VM32 jquery-1.12.4.js:7402
  tick @ VM32 jquery-1.12.4.js:7747
  jQuery.fx.tick @ VM32 jquery-1.12.4.js:8069
  setInterval (async)
  jQuery.fx.start @ VM32 jquery-1.12.4.js:8093
  jQuery.fx.timer @ VM32 jquery-1.12.4.js:8083
  Animation @ VM32 jquery-1.12.4.js:7823
  doAnimation @ VM32 jquery-1.12.4.js:7926
  dequeue @ VM32 jquery-1.12.4.js:4157
  (anonymous) @ VM32 jquery-1.12.4.js:4201
  each @ VM32 jquery-1.12.4.js:370
  each @ VM32 jquery-1.12.4.js:137
  queue @ VM32 jquery-1.12.4.js:4194
  animate @ VM32 jquery-1.12.4.js:7937
  jQuery.fn.(anonymous function) @ VM32 jquery-1.12.4.js:8053
  (anonymous) @ VM83:24
  fire @ VM32 jquery-1.12.4.js:3232
  add @ VM32 jquery-1.12.4.js:3291
  jQuery.fn.ready @ VM32 jquery-1.12.4.js:3542
  (anonymous) @ VM83:1
  (anonymous) @ VM32 jquery-1.12.4.js:349
  globalEval @ VM32 jquery-1.12.4.js:350
  text script @ VM32 jquery-1.12.4.js:10372
  ajaxConvert @ VM32 jquery-1.12.4.js:9332
  done @ VM32 jquery-1.12.4.js:9789
  callback @ VM32 jquery-1.12.4.js:10311
  send @ VM32 jquery-1.12.4.js:10321
  ajax @ VM32 jquery-1.12.4.js:9738
  jQuery._evalUrl @ VM32 jquery-1.12.4.js:9902
  domManip @ VM32 jquery-1.12.4.js:6086
  append @ VM32 jquery-1.12.4.js:6269
  (anonymous) @ VM32 jquery-1.12.4.js:6375
  access @ VM32 jquery-1.12.4.js:4399
  html @ VM32 jquery-1.12.4.js:6338
  success @ Flights:18215
  fire @ VM32 jquery-1.12.4.js:3232
  fireWith @ VM32 jquery-1.12.4.js:3362
  done @ VM32 jquery-1.12.4.js:9840
  callback @ VM32 jquery-1.12.4.js:10311
  XMLHttpRequest.send (async)
  send @ VM32 jquery-1.12.4.js:10254
  ajax @ VM32 jquery-1.12.4.js:9738
  (anonymous) @ Flights:18211
  dispatch @ VM32 jquery-1.12.4.js:5226
  elemData.handle @ VM32 jquery-1.12.4.js:4878
  maps.googleapis.com/maps/gen_204?target=api&amp;ev=api_alreadyloaded&amp;client=&amp;key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg&amp;cad=src:apiv3,token:4u7gju54e3,ts:nhesob:1 GET http://maps.googleapis.com/maps/gen_204?target=api&amp;ev=api_alreadyloaded&amp;client=&amp;key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg&amp;cad=src:apiv3,token:4u7gju54e3,ts:nhesob 0 ()
  Image (async)
  LY.b @ stats.js:5
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:158
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:63
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:60
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:63
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:135
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:60
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:135
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:60
  (anonymous) @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:135
  Rd @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:63
  Qd.va @ js?key=AIzaSyASHcSQGj-zxu3xPF5e07MFU4L_jxxBXcg:135
  (anonymous) @ util.js:1
  2334VM95:46 Uncaught TypeError: jQuery.easing[jQuery.easing.def] is not a function
      at Object.swing (eval at &lt;anonymous&gt; (VM32 jquery-1.12.4.js:349), &lt;anonymous&gt;:46:42)
      at init.run (VM32 jquery-1.12.4.js:7402)
      at tick (VM32 jquery-1.12.4.js:7747)
      at jQuery.fx.tick (VM32 jquery-1.12.4.js:8069)
  swing @ VM95:46
  run @ VM32 jquery-1.12.4.js:7402
  tick @ VM32 jquery-1.12.4.js:7747
  jQuery.fx.tick @ VM32 jquery-1.12.4.js:8069
  setInterval (async)
  jQuery.fx.start @ VM32 jquery-1.12.4.js:8093
  jQuery.fx.timer @ VM32 jquery-1.12.4.js:8083
  Animation @ VM32 jquery-1.12.4.js:7823
  doAnimation @ VM32 jquery-1.12.4.js:7926
  dequeue @ VM32 jquery-1.12.4.js:4157
  (anonymous) @ VM32 jquery-1.12.4.js:4201
  each @ VM32 jquery-1.12.4.js:370
  each @ VM32 jquery-1.12.4.js:137
  queue @ VM32 jquery-1.12.4.js:4194
  animate @ VM32 jquery-1.12.4.js:7937
  jQuery.fn.(anonymous function) @ VM32 jquery-1.12.4.js:8053
  (anonymous) @ VM83:24
  fire @ VM32 jquery-1.12.4.js:3232
  add @ VM32 jquery-1.12.4.js:3291
  jQuery.fn.ready @ VM32 jquery-1.12.4.js:3542
  (anonymous) @ VM83:1
  (anonymous) @ VM32 jquery-1.12.4.js:349
  globalEval @ VM32 jquery-1.12.4.js:350
  text script @ VM32 jquery-1.12.4.js:10372
  ajaxConvert @ VM32 jquery-1.12.4.js:9332
  done @ VM32 jquery-1.12.4.js:9789
  callback @ VM32 jquery-1.12.4.js:10311
  send @ VM32 jquery-1.12.4.js:10321
  ajax @ VM32 jquery-1.12.4.js:9738
  jQuery._evalUrl @ VM32 jquery-1.12.4.js:9902
  domManip @ VM32 jquery-1.12.4.js:6086
  append @ VM32 jquery-1.12.4.js:6269
  (anonymous) @ VM32 jquery-1.12.4.js:6375
  access @ VM32 jquery-1.12.4.js:4399
  html @ VM32 jquery-1.12.4.js:6338
  success @ Flights:18215
  fire @ VM32 jquery-1.12.4.js:3232
  fireWith @ VM32 jquery-1.12.4.js:3362
  done @ VM32 jquery-1.12.4.js:9840
  callback @ VM32 jquery-1.12.4.js:10311
  XMLHttpRequest.send (async)
  send @ VM32 jquery-1.12.4.js:10254
  ajax @ VM32 jquery-1.12.4.js:9738
  (anonymous) @ Flights:18211
  dispatch @ VM32 jquery-1.12.4.js:5226
  elemData.handle @ VM32 jquery-1.12.4.js:4878
  </code></pre>
  
  <p>Why is this happening and how can I fix it? Any help would be appreciated.</p>