{"id":8002,"date":"2015-11-19T00:01:06","date_gmt":"2015-11-19T00:01:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/19\/select2-doesnt-work-when-embedded-in-a-bootstrap-modal-open-source-projects-select2-select2\/"},"modified":"2022-08-30T15:03:04","modified_gmt":"2022-08-30T15:03:04","slug":"select2-doesnt-work-when-embedded-in-a-bootstrap-modal-open-source-projects-select2-select2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/19\/select2-doesnt-work-when-embedded-in-a-bootstrap-modal-open-source-projects-select2-select2\/","title":{"rendered":"Select2 doesn&#39;t work when embedded in a bootstrap modal-open source projects select2\/select2"},"content":{"rendered":"<p>When I use a select2 (input) in bootstrap modal, I can&#8217;t type anything into it. It&#8217;s like disabled? Outside he modal select2 works fine.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/h0I0M.jpg\" \/><\/p>\n<p>working example: http:\/\/jsfiddle.net\/byJy8\/1\/ code:<\/p>\n<pre><code>\n\n  \n    \u00d7\n    <\/code><\/pre>\n<h3 id=\"myModalLabel\"><code>Panel<\/code><\/h3>\n<pre>\n  \n  \n\n\n\n\n\n\n  Numer\n  \n     \n    \n  \n\n\n  \n  \n    Close\n    Save changes\n  \n\n<\/pre>\n<p><code>adn js<\/code><\/p>\n<pre><code><code>$(\"#vdn_number\").select2({\n    placeholder: \"00000\",\n    minimumInputLength: 2,\n    ajax: {\n        url: \"getAjaxData\/\",\n        dataType: 'json',\n        type: \"POST\",\n        data: function (term, page) {\n            return {\n                q: term, \/\/ search term\n                col: 'vdn'\n            };\n        },\n        results: function (data) { \/\/ parse the results into the format expected by Select2.\n            \/\/ since we are using custom formatting functions we do not need to alter remote JSON data\n            return {results: data};\n        }\n    }\n});\n<\/code><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When I use a select2 (input) in bootstrap modal, I can&#8217;t type anything into it. It&#8217;s like disabled? Outside he modal select2 works fine. working example: http:\/\/jsfiddle.net\/byJy8\/1\/ code: \u00d7 Panel Numer Close Save changes adn js $(&#8220;#vdn_number&#8221;).select2({ placeholder: &#8220;00000&#8221;, minimumInputLength: 2, ajax: { url: &#8220;getAjaxData\/&#8221;, dataType: &#8216;json&#8217;, type: &#8220;POST&#8221;, data: function (term, page) { return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8002","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8002","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8002"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8002\/revisions"}],"predecessor-version":[{"id":8708,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8002\/revisions\/8708"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}