title: Bootstrap-select plugin not working in partial view in asp.net core mvc
body: <p>I'm using a partial view using jquery's $.get() method but whenever I load the page the select element disappeared from the page. it shows in &quot;Inspect element&quot; section of a browser but I didn't see any error.</p>
  <p>This error only occurs in partial views. If I load the page as View instead of Partial view then that plugin will work perfectly.</p>
  <p>here is my code.
  Please help if you know anything about this.</p>
  <blockquote>
  <p>NOTE:
  <strong>Since partial view doesn't support @section so I have to put all the script elements in the beginning of the body tag so that all scripts from partial view will be register in dom after the _Layout page scripts. Otherwise I got the error like '$ is not defined' etc</strong></p>
  </blockquote>
  <blockquote>
  <p>This is my _Layout.cshtml</p>
  </blockquote>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot; /&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot; /&gt;
      &lt;title&gt;Website Name&lt;/title&gt;
      &lt;link rel=&quot; shortcut icon&quot; type=&quot;image/x-icon&quot; href=&quot;~/logo-icon.png&quot; sizes=&quot;16x16&quot; /&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;~/css/bootstrap.min.css&quot; /&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;~/DataTables/datatables.min.css&quot; /&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;~/css/font-awesome.min.css&quot; /&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;~/css/bootstrap-select.min.css&quot; /&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;~/css/style.css&quot; /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/js/jquery-3.5.1.min.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/js/popper.min.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/js/bootstrap-select.min.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/DataTables/datatables.min.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/js/customized-datatable.js&quot;&gt;&lt;/script&gt;
  
  
      &lt;!--For font awesom 5.14.0 icons --&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/js/font-awesome-5.14.0.js&quot;&gt;&lt;/script&gt;
  
      &lt;!--Custom bootstrap modal--&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/js/psychic-dev.js&quot;&gt;&lt;/script&gt;
  
  
      @await Component.InvokeAsync(&quot;Menu&quot;)
      @await Component.InvokeAsync(&quot;ChangePassword&quot;)
      @await Component.InvokeAsync(&quot;UserProfile&quot;)
      @await Component.InvokeAsync(&quot;Profile&quot;)
  
      &lt;div class=&quot;m-4&quot;&gt;
          @RenderBody()
      &lt;/div&gt;
  
  
      @RenderSection(&quot;script&quot;, required: false)
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <blockquote>
  <p>This is a View (in which I'll inject different partial views)</p>
  </blockquote>
  <pre><code>
  &lt;div class=&quot;container-fluid p-3 shadow-lg border&quot; style=&quot;height:80vh;&quot;&gt;
      &lt;div id=&quot;fund-rule-div&quot;&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  @section script{
  
      &lt;script type=&quot;text/javascript&quot; src=&quot;~/ui-js/fund-rule-ui/fund-rule.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot;&gt;
          $(document).ready(function () {
              $.get('@Url.Action(&quot;FundRuleIndex&quot;)', function (data) {
                  $('#fund-rule-div').html(data);
              });
  
  
          });
      &lt;/script&gt;
  }
  </code></pre>
  <blockquote>
  <p>This is my partial view in which bootstrap-select is not working (not appearing at all)</p>
  </blockquote>
  <pre><code>@model Society.Excel.WebApp.ViewModels.FundRuleViewModel
  
  
  &lt;ul class=&quot;breadcrumb&quot;&gt;
      &lt;li class=&quot;breadcrumb-item&quot;&gt;&lt;a asp-action=&quot;Index&quot; asp-controller=&quot;FundRule&quot;&gt;Index&lt;/a&gt;&lt;/li&gt;
      &lt;li class=&quot;breadcrumb-item active&quot;&gt;Fund Rule&lt;/li&gt;
  &lt;/ul&gt;
  
  
  &lt;form method=&quot;post&quot; class=&quot;form-horizontal &quot; role=&quot;form&quot; id=&quot;add-fund-rule-form&quot; onsubmit=&quot;addUpdateFundRule(event)&quot;&gt;
  
      &lt;h5 class=&quot;text-info&quot;&gt;Fund Rule&lt;/h5&gt;
      &lt;hr class=&quot;border-info&quot; /&gt;
  
      &lt;div class=&quot;row &quot;&gt;
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;div class=&quot;custom-control custom-switch&quot;&gt;
                      &lt;input asp-for=&quot;FundRuleModel.IsActive&quot; type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; id=&quot;IsActive&quot; checked=&quot;checked&quot;&gt;
                      &lt;label class=&quot;custom-control-label&quot; for=&quot;IsActive&quot;&gt;Is Active?&lt;/label&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;col-md-9&quot;&gt;
              &lt;label class=&quot;col-form-label&quot;&gt;&lt;strong&gt;Rule for :&gt;&gt;&lt;/strong&gt; &lt;/label&gt;
              &lt;div class=&quot;custom-control custom-radio custom-control-inline&quot;&gt;
                  &lt;input asp-for=&quot;FundRuleModel.IsIncludedInRegularInvoice&quot; id=&quot;IsForSystemGeneration_true&quot; class=&quot;custom-control-input&quot; type=&quot;radio&quot; value=&quot;true&quot; checked&gt;
                  &lt;label class=&quot;custom-control-label&quot; for=&quot;IsForSystemGeneration_true&quot;&gt;Regular Invoice&lt;/label&gt;
              &lt;/div&gt;
              &lt;div class=&quot;custom-control custom-radio custom-control-inline&quot;&gt;
                  &lt;input asp-for=&quot;FundRuleModel.IsIncludedInRegularInvoice&quot; id=&quot;IsForSystemGeneration_false&quot; class=&quot;custom-control-input&quot; type=&quot;radio&quot; value=&quot;false&quot;&gt;
                  &lt;label class=&quot;custom-control-label&quot; for=&quot;IsForSystemGeneration_false&quot;&gt;Manually Created Invoice&lt;/label&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  
      &lt;div class=&quot;row&quot;&gt;
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group &quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.FundRuleName&quot; for=&quot;FundRuleName&quot;&gt;Name &lt;span class=&quot;text-danger&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;input type=&quot;text&quot; asp-for=&quot;FundRuleModel.FundRuleName&quot; class=&quot;form-control form-control-sm &quot; id=&quot;FundRuleName&quot; required /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.FundRuleTypeName&quot; for=&quot;FundRuleType&quot;&gt;Rule Type &lt;span class=&quot;text-danger&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;select asp-for=&quot;FundRuleModel.FundRuleTypeRid&quot; asp-items=&quot;@(new SelectList(Model.FundRuleTypes,&quot;FundRuleTypeRid&quot;,&quot;FundRuleTypeName&quot;))&quot; class=&quot;selectpicker form-control form-control-sm &quot; data-live-search=&quot;true&quot; data-size=&quot;5&quot; id=&quot;FundRuleType&quot; required&gt;
                      &lt;option selected disabled value=&quot;&quot;&gt;Select One&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.FundCycleName&quot; for=&quot;FundCycleName&quot;&gt;Fund Cycle&lt;span class=&quot;text-danger&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;select asp-for=&quot;FundRuleModel.FundCycleRid&quot; asp-items=&quot;@(new SelectList(Model.FundCycles,&quot;FundCycleRid&quot;,&quot;FundCycleName&quot;))&quot; class=&quot;selectpicker form-control form-control-sm &quot; id=&quot;FundCycleName&quot; required&gt;
                      &lt;option selected disabled value=&quot;&quot;&gt;Select One&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.Amount&quot; for=&quot;Amount&quot;&gt;Amount &lt;span class=&quot;text-danger&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;input asp-for=&quot;FundRuleModel.Amount&quot; class=&quot;form-control form-control-sm &quot; id=&quot;Amount&quot; required /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  
      &lt;div class=&quot;row&quot;&gt;
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.FundCalculationTypeName&quot; for=&quot;FundCalculationTypeName&quot;&gt;Calculation Type &lt;span class=&quot;text-danger&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;select asp-for=&quot;FundRuleModel.FundCalculationTypeRid&quot; asp-items=&quot;@(new SelectList(Model.CalculationTypes,&quot;FundCalculationTypeRid&quot;,&quot;FundCalculationTypeName&quot;))&quot; class=&quot;selectpicker form-control form-control-sm &quot; id=&quot;FundCalculationTypeName&quot; required&gt;
                      &lt;option selected disabled value=&quot;&quot;&gt;Select One&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.FlatCalculationFilterName&quot; for=&quot;FlatCalculationFilterRid&quot;&gt;Flat Filters&lt;span class=&quot;text-danger&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;select asp-for=&quot;FundRuleModel.FlatCalculationFilterRid&quot; asp-items=&quot;@(new SelectList(Model.CalculationFlatFilters,&quot;FlatCalculationFilterRid&quot;,&quot;FlatCalculationFilterName&quot;))&quot; class=&quot;selectpicker form-control form-control-sm &quot; id=&quot;FlatCalculationFilterRid&quot; required&gt;
                      &lt;option selected disabled value=&quot;&quot;&gt;Select One&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.ApplicableDate&quot; for=&quot;ApplicableDate&quot;&gt;Applicable Date &lt;span class=&quot;text-danger&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
                  &lt;input type=&quot;date&quot; asp-for=&quot;FundRuleModel.ApplicableDate&quot; class=&quot;form-control form-control-sm &quot; id=&quot;ApplicableDate&quot; required /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class=&quot;col-md-3&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.EndDate&quot; for=&quot;EndDate&quot;&gt;End Date&lt;/label&gt;
                  &lt;input type=&quot;date&quot; asp-for=&quot;FundRuleModel.EndDate&quot; class=&quot;form-control form-control-sm &quot; id=&quot;EndDate&quot; /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  
      &lt;div class=&quot;row &quot;&gt;
          &lt;div class=&quot;col-md-12&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;label asp-for=&quot;FundRuleModel.Narration&quot; for=&quot;Narration&quot;&gt;Narration&lt;/label&gt;
                  &lt;textarea asp-for=&quot;FundRuleModel.Narration&quot; class=&quot;form-control form-control-sm &quot; id=&quot;Narration&quot;&gt;&lt;/textarea&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  
      &lt;div class=&quot;row &quot;&gt;
          &lt;div class=&quot;col-md-12 text-center&quot;&gt;
              &lt;div class=&quot;form-group&quot;&gt;
                  &lt;button class=&quot;btn btn-sm btn-success &quot; type=&quot;submit&quot;&gt;Save&lt;/button&gt;
                  &lt;button type=&quot;button&quot; onclick=&quot;fundRuleIndexPage()&quot; class=&quot;btn btn-sm btn-outline-dark &quot;&gt;Cancel&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>