久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='E4kIX'></tfoot>
    <legend id='E4kIX'><style id='E4kIX'><dir id='E4kIX'><q id='E4kIX'></q></dir></style></legend>

      <small id='E4kIX'></small><noframes id='E4kIX'>

        <bdo id='E4kIX'></bdo><ul id='E4kIX'></ul>
        <i id='E4kIX'><tr id='E4kIX'><dt id='E4kIX'><q id='E4kIX'><span id='E4kIX'><b id='E4kIX'><form id='E4kIX'><ins id='E4kIX'></ins><ul id='E4kIX'></ul><sub id='E4kIX'></sub></form><legend id='E4kIX'></legend><bdo id='E4kIX'><pre id='E4kIX'><center id='E4kIX'></center></pre></bdo></b><th id='E4kIX'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='E4kIX'><tfoot id='E4kIX'></tfoot><dl id='E4kIX'><fieldset id='E4kIX'></fieldset></dl></div>

        jQuery:與在不適當(dāng)?shù)臅r(shí)間執(zhí)行的 removeData() 沖突

        jQuery: Conflict with removeData() executing at inadequate times(jQuery:與在不適當(dāng)?shù)臅r(shí)間執(zhí)行的 removeData() 沖突)
            <bdo id='XYYcx'></bdo><ul id='XYYcx'></ul>

            <small id='XYYcx'></small><noframes id='XYYcx'>

              <legend id='XYYcx'><style id='XYYcx'><dir id='XYYcx'><q id='XYYcx'></q></dir></style></legend>
              <i id='XYYcx'><tr id='XYYcx'><dt id='XYYcx'><q id='XYYcx'><span id='XYYcx'><b id='XYYcx'><form id='XYYcx'><ins id='XYYcx'></ins><ul id='XYYcx'></ul><sub id='XYYcx'></sub></form><legend id='XYYcx'></legend><bdo id='XYYcx'><pre id='XYYcx'><center id='XYYcx'></center></pre></bdo></b><th id='XYYcx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XYYcx'><tfoot id='XYYcx'></tfoot><dl id='XYYcx'><fieldset id='XYYcx'></fieldset></dl></div>

                  <tbody id='XYYcx'></tbody>
                • <tfoot id='XYYcx'></tfoot>
                  本文介紹了jQuery:與在不適當(dāng)?shù)臅r(shí)間執(zhí)行的 removeData() 沖突的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我有一個(gè)模式窗口,用于更新或添加新對(duì)象Store.

                  I have a modal window used to update or add a new object Store.

                  此模式被遠(yuǎn)程調(diào)用,其信息從 ASP.NET 中構(gòu)造的 GET 方法加載.

                  This modal is called remotely which information is loaded from a GET method constructed in ASP.NET.

                  調(diào)用模態(tài)的按鈕:

                  <div class="btn-group" id="modalbutton">
                      <a id="createEditStoreModal" data-toggle="modal" asp-action="Create" 
                           data-target="#modal-action-store" class="btn btn-primary">
                              <i class="glyphicon glyphicon-plus"></i>  NEW STORE
                          </a>
                  </div>
                  

                  模態(tài)的HTML:

                  @model Application.Models.ApplicationviewModels.StoreIndexData
                  @using Application.Models
                  
                  <form asp-action="Create" role="form">    
                          @await Html.PartialAsync("_ModalHeader", new ModalHeader
                      { Heading = String.Format("Actualización de Modelo: Tiendas") })
                  
                          <div asp-validation-summary="ModelOnly" class="text-danger"></div>
                          <div class="modal-body form-horizontal">
                              <div class="form-group">
                                  <label asp-for="DepartmentID" class="col-md-2 control-label"></label>
                                  <div class="col-md-10">
                                      <select asp-for="DepartmentID" class="form-control"
                                              asp-items="@(new SelectList(@ViewBag.ListofDepartment,"DepartmentID","DepartmentName"))"></select>
                                  </div>
                              </div>
                              <div class="form-group">
                                  <label class="col-md-2 control-label">Distrito</label>
                                  <div class="col-md-10">
                                      <select class="form-control" id="DistrictID" name="DistrictID" asp-for="DistrictID"
                                              asp-items="@(new SelectList(@ViewBag.ListofDistrict,"DistrictID","DistrictName"))"></select>
                                  </div>
                              </div>
                              {... more elements}
                         </div>
                  </form>
                  

                  GET方法:

                      public IActionResult Create(int? id)
                      {
                          List<Department> DepartmentList = new List<Department>();
                          DepartmentList = (from department in _context.Departments
                                            select department).ToList();
                          DepartmentList.Insert(0, new Department { DepartmentID = 0, DepartmentName = "-- Seleccione Departamento --" });
                          ViewBag.ListofDepartment = DepartmentList;
                  
                          StoreIndexData edit = new StoreIndexData();
                          List<District> ListofDistrict = new List<District>();
                          ListofDistrict.Insert(0, new District { DistrictID = 0, DistrictName = "-- PRUEBA --" });
                          ViewBag.ListofDistrict = ListofDistrict;
                  
                          return PartialView("~/Views/Shared/Stores/_Create.cshtml");
                      }
                  

                  問(wèn)題:

                  我有以下 jQuery,一旦模式打開,它就會(huì)為 DistrictID 分配一個(gè)值:

                  I have the following jQuery which asigns a value to DistrictID once the modal opens:

                  <script type="text/javascript">
                  
                      var wasclicked = 0;
                      var $this = this;
                  
                      $(document).ready(function () {
                  
                          document.getElementById("modalbutton").onclick = function () {
                              //is AddNew Store button is hitted, this var = 1
                              wasclicked = 1;
                          };
                  
                          $('#modal-action-store').on('hidden.bs.modal', function () {
                              //global.wasclicked = 0;
                              wasclicked = 0;
                              $(this).removeData('bs.modal');
                          });
                  
                          $('#modal-action-store').on('shown.bs.modal', function (e) {
                              console.log($('#DistrictID').length);
                              //if wasclicked equals 1 that means we are in the AddNew Store scenario.
                              if (wasclicked == 1) {
                                  //a default value is sent to District dropdownlist
                                  var items = "<option value='0'>-- Seleccione Distrito --</option>";
                                  $('#DistrictID').html(items);
                              };
                          });
                      });
                  </script>
                  

                  現(xiàn)在的問(wèn)題是,在這行 jQuery 執(zhí)行之后,分配給 DistrictID 的值被 :

                  The problem right now is that after this line jQuery is executed, the value that was assigned to DistrictID gets overwritten by :

                    ViewBag.ListofDistrict = ListofDistrict; //"-- PRUEBA --"
                  

                  而這一行丟失了:

                  var items = "<option value='0'>-- Seleccione Distrito --</option>";
                  

                  我懷疑來(lái)自 Controller 的信息會(huì)覆蓋模態(tài)中的 jQuery 的任何結(jié)果.

                  What I suspect is that the information coming from the Controller overwrites any result from jQuery over the in the modal.

                  調(diào)試后我發(fā)現(xiàn)了三個(gè)不同的時(shí)刻:

                  After debugging I have identified three diferent moments:

                  時(shí)刻 1:我們第一次打開模式

                  • 模態(tài)尚未打開,jQuery 正在執(zhí)行
                  • 因此它無(wú)法識(shí)別 DistrictID
                  • GET 操作的結(jié)果填充模態(tài)的輸入.

                  時(shí)刻 2 - 第 1 部分:我們第二次打開模式

                  • 這次模態(tài)框在 jQuery 執(zhí)行之前打開
                  • 在我們從 jQuery 分配值之前,DistrictID 具有來(lái)自 GET 方法的值
                  • This time the modal opens before the jQuery is executed
                  • The DistrictID has the value from the GET Method before we assign the value from jQuery

                  時(shí)刻 2 - 第 2 部分:分配來(lái)自 jQuery 的值時(shí)

                  • 來(lái)自 jQuery 的值被分配給 DistrictID
                  • 此值將被 GET 操作的結(jié)果覆蓋

                  問(wèn)題:

                  誰(shuí)能解釋或幫助我了解可能導(dǎo)致這種情況的原因?我還能做些什么來(lái)找出這背后的原因?

                  Can anyone explain or help me understand what might be causing this? What else can I do to identify the reason behind this?

                  推薦答案

                  嘗試將html到districtID的分配從你的主視圖移動(dòng)到modal的document.ready彈出視圖.

                  Trying moving the assigning of html to districtID from your main view to the document.ready of modal popUp view.

                      @model Application.Models.ApplicationviewModels.StoreIndexData
                      @using Application.Models
                  
                      <form asp-action="Create" role="form">    
                              @await Html.PartialAsync("_ModalHeader", new ModalHeader
                          { Heading = String.Format("Actualización de Modelo: Tiendas") })
                  
                              <div asp-validation-summary="ModelOnly" class="text-danger"></div>
                              <div class="modal-body form-horizontal">
                                  <div class="form-group">
                                      <label asp-for="DepartmentID" class="col-md-2 control-label"></label>
                                      <div class="col-md-10">
                                          <select asp-for="DepartmentID" class="form-control"
                                                  asp-items="@(new SelectList(@ViewBag.ListofDepartment,"DepartmentID","DepartmentName"))"></select>
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label class="col-md-2 control-label">Distrito</label>
                                      <div class="col-md-10">
                                          <select class="form-control" id="DistrictID" name="DistrictID" asp-for="DistrictID"
                                                  asp-items="@(new SelectList(@ViewBag.ListofDistrict,"DistrictID","DistrictName"))"></select>
                                      </div>
                                  </div>
                                  {... more elements}
                             </div>
                      </form>
                  
                  <script type="text/javascript">
                  
                      $(document).ready(function () {
                              //if wasclicked equals 1 that means we are in the AddNew Store scenario.
                              if (wasclicked == 1) {
                                  //a default value is sent to District dropdownlist
                                  var items = "<option value='0'>-- Seleccione Distrito --</option>";
                                  $('#DistrictID').html(items);
                              }
                      });
                  
                  </script>
                  

                  PS:也可以使用默認(rèn)選項(xiàng).參考下面的代碼.

                  PS: Default option can be also be used. refer the below code.

                  <div class="form-group">
                   <label class="col-md-2 control-label">Distrito</label>
                    <div class="col-md-10">
                     <select class="form-control" id="DistrictID" name="DistrictID" asp-for="DistrictID" asp-items="@(new SelectList(@ViewBag.ListofDistrict,"DistrictID","DistrictName"))">
                       <option value='0'>-- Seleccione Distrito --</option>
                    </select>
                   </div>
                  </div>
                  

                  這篇關(guān)于jQuery:與在不適當(dāng)?shù)臅r(shí)間執(zhí)行的 removeData() 沖突的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個(gè)多邊形點(diǎn)是否在傳單中的另一個(gè)內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)
                  Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在彈出窗口中獲取標(biāo)記的緯度和經(jīng)度)

                • <legend id='3NeF0'><style id='3NeF0'><dir id='3NeF0'><q id='3NeF0'></q></dir></style></legend>
                  <i id='3NeF0'><tr id='3NeF0'><dt id='3NeF0'><q id='3NeF0'><span id='3NeF0'><b id='3NeF0'><form id='3NeF0'><ins id='3NeF0'></ins><ul id='3NeF0'></ul><sub id='3NeF0'></sub></form><legend id='3NeF0'></legend><bdo id='3NeF0'><pre id='3NeF0'><center id='3NeF0'></center></pre></bdo></b><th id='3NeF0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3NeF0'><tfoot id='3NeF0'></tfoot><dl id='3NeF0'><fieldset id='3NeF0'></fieldset></dl></div>

                  <small id='3NeF0'></small><noframes id='3NeF0'>

                      • <bdo id='3NeF0'></bdo><ul id='3NeF0'></ul>

                              <tbody id='3NeF0'></tbody>
                            <tfoot id='3NeF0'></tfoot>
                            主站蜘蛛池模板: 欧美日韩中文字幕 | 国产精品成人一区二区三区夜夜夜 | 91国自产| 在线播放中文字幕 | 日本国产一区二区 | 雨宫琴音一区二区在线 | 国产在线中文字幕 | 亚欧洲精品在线视频免费观看 | 亚洲免费视频播放 | 亚洲手机视频在线 | 欧美日韩免费在线 | 91.色| 欧美日韩视频 | 成人国产精品免费观看 | 国精产品一区一区三区免费完 | 欧美xxxx在线 | 久久激情视频 | 一区二区三区在线电影 | 国产日韩欧美激情 | 成人性视频免费网站 | 天天综合成人网 | 亚洲成av| 久久一级 | 播放一级黄色片 | 久久69精品久久久久久久电影好 | 亚洲一区二区精品 | 亚洲精品成人 | 亚欧午夜| 91福利电影在线观看 | 久久国产一区二区三区 | 中文字幕一区二区视频 | 欧美精品一区二区三区在线 | 国产三级大片 | 好姑娘高清在线观看电影 | 夜夜精品浪潮av一区二区三区 | 中文字幕视频免费 | 一区二区三区四区在线视频 | 视频一区在线观看 | 亚洲一区二区三区免费在线 | 国产日韩欧美中文 | 中文字幕亚洲一区二区三区 |