pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <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="gcq00mk" id='E4kIX'><tfoot id='E4kIX'></tfoot><dl id='E4kIX'><fieldset id='E4kIX'></fieldset></dl></div>

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

        jQuery: Conflict with removeData() executing at inadequate times(jQuery:與在不適當(dāng)?shù)臅r間執(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="0ksgkki" 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間執(zhí)行的 removeData() 沖突的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我有一個模式窗口,用于更新或添加新對象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");
                      }
                  

                  問題:

                  我有以下 jQuery,一旦模式打開,它就會為 DistrictID 分配一個值:

                  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)在的問題是,在這行 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>";
                  

                  我懷疑來自 Controller 的信息會覆蓋模態(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)了三個不同的時刻:

                  After debugging I have identified three diferent moments:

                  時刻 1:我們第一次打開模式

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

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

                  • 這次模態(tài)框在 jQuery 執(zhí)行之前打開
                  • 在我們從 jQuery 分配值之前,DistrictID 具有來自 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

                  時刻 2 - 第 2 部分:分配來自 jQuery 的值時

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

                  問題:

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

                  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的分配從你的主視圖移動到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間執(zhí)行的 removeData() 沖突的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點(diǎn)是否在傳單中的另一個內(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="egoe2sg" 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>
                            主站蜘蛛池模板: 微动开关厂家-东莞市德沃电子科技有限公司 | 医学模型生产厂家-显微手术模拟训练器-仿真手术模拟训练系统-北京医教科技 | 不锈钢法兰-碳钢法兰-法兰盘生产加工厂家-[鼎捷峰]-不锈钢法兰-碳钢法兰-法兰盘生产加工厂家-[鼎捷峰] | 依维柯自动挡房车,自行式国产改装房车,小型房车价格,中国十大房车品牌_南京拓锐斯特房车 - 南京拓锐斯特房车 | 压砖机_电动螺旋压力机_粉末成型压力机_郑州华隆机械tel_0371-60121717 | 东莞喷砂机-喷砂机-喷砂机配件-喷砂器材-喷砂加工-东莞市协帆喷砂机械设备有限公司 | 分子精馏/精馏设备生产厂家-分子蒸馏工艺实验-新诺舜尧(天津)化工设备有限公司 | 留学生辅导网-在线课程论文辅导-留学生挂科申诉机构 | 玉米深加工机械,玉米加工设备,玉米加工机械等玉米深加工设备制造商-河南成立粮油机械有限公司 | 北京浩云律师事务所-法律顾问_企业法务_律师顾问_公司顾问 | 全自动过滤器_反冲洗过滤器_自清洗过滤器_量子除垢环_量子环除垢_量子除垢 - 安士睿(北京)过滤设备有限公司 | 生物制药洁净车间-GMP车间净化工程-食品净化厂房-杭州波涛净化设备工程有限公司 | 大数据营销公司_舆情监测软件_上海SEO公司-文军营销官网 | 【ph计】|在线ph计|工业ph计|ph计厂家|ph计价格|酸度计生产厂家_武汉吉尔德科技有限公司 | 石家庄救护车出租_重症转院_跨省跨境医疗转送_活动赛事医疗保障_康复出院_放弃治疗_腾康26年医疗护送转诊团队 | nalgene洗瓶,nalgene量筒,nalgene窄口瓶,nalgene放水口大瓶,浙江省nalgene代理-杭州雷琪实验器材有限公司 | 全自动端子机|刺破式端子压接机|全自动双头沾锡机|全自动插胶壳端子机-东莞市傅氏兄弟机械设备有限公司 | 细沙回收机-尾矿干排脱水筛设备-泥石分离机-建筑垃圾分拣机厂家-青州冠诚重工机械有限公司 | 真空吸污车_高压清洗车厂家-程力专用汽车股份有限公司官网 | 滑石粉,滑石粉厂家,超细滑石粉-莱州圣凯滑石有限公司 | 冷水机-工业冷水机-冷水机组-欧科隆品牌保障 | 山东活动策划|济南活动公司|济南公关活动策划-济南锐嘉广告有限公司 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 南京种植牙医院【官方挂号】_南京治疗种植牙医院那个好_南京看种植牙哪里好_南京茀莱堡口腔医院 尼龙PA610树脂,尼龙PA612树脂,尼龙PA1010树脂,透明尼龙-谷骐科技【官网】 | 润滑油加盟_润滑油厂家_润滑油品牌-深圳市沃丹润滑科技有限公司 琉璃瓦-琉璃瓦厂家-安徽盛阳新型建材科技有限公司 | 企小优-企业数字化转型服务商_网络推广_网络推广公司 | 沈阳液压泵_沈阳液压阀_沈阳液压站-沈阳海德太科液压设备有限公司 | 水平筛厂家-三轴椭圆水平振动筛-泥沙震动筛设备_山东奥凯诺矿机 包装设计公司,产品包装设计|包装制作,包装盒定制厂家-汇包装【官方网站】 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 818手游网_提供当下热门APP手游_最新手机游戏下载 | pos机办理,智能/扫码/二维码/微信支付宝pos机-北京万汇通宝商贸有限公司 | 广西绿桂涂料--承接隔热涂料、隔音涂料、真石漆、多彩仿石漆等涂料工程双包施工 | 淘剧影院_海量最新电视剧,免费高清电影随心观看 | 无锡装修装潢公司,口碑好的装饰装修公司-无锡索美装饰设计工程有限公司 | 防腐木批发价格_深圳_惠州_东莞防腐木厂家_森源(深圳)防腐木有限公司 | PAS糖原染色-CBA流式多因子-明胶酶谱MMP-上海研谨生物科技有限公司 | 踏板力计,制动仪,非接触多功能速度仪,逆反射系数测试仪-创宇 | 999范文网_优质范文下载写作帮手| MES系统-WMS系统-MES定制开发-制造执行MES解决方案-罗浮云计算 | 旗杆生产厂家_不锈钢锥形旗杆价格_铝合金电动旗杆-上海锥升金属科技有限公司 | 耳模扫描仪-定制耳机设计软件-DLP打印机-asiga打印机-fitshape「飞特西普」 |