javascript - jQuery remodal 弹出窗口将标签href添加到url
问题描述
我有一段 html,基本上看起来像这样:
<a id="popap" style="display:none;" href="#modal">Call the modal with data-remodal-id="modal"</a>
然后是 remodal 弹出窗口的定义,如下所示:
<div class="remodal" style="width:60%" data-remodal-id="modal">
<div style="width:100%; text-align:center;">
<canvas class="canvas" height="160"></canvas>
</div>
<div class="hideit">
<button data-remodal-action="close" class="remodal-close"></button>
<div class="row">
<div class="modalMainTitle">
<i class="far fa-save fa-3x"></i>
<h1>Add to search List</h1>
</div>
<p>
Comment:
</p>
<textarea id="TextArea1" rows="2" cols="20"></textarea>
</div>
<div class="row" style="padding:0 41.64% ;">
<p>Rating: </p>
<fieldset class="rating" id="ratingSystem">
<input type="radio" id="star5" name="rating" value="5" autocomplete="off" /><label class="full" for="star5" title="Awesome - 5 stars"></label>
<input type="radio" id="star4" name="rating" value="4" autocomplete="off" /><label class="full" for="star4" title="Pretty good - 4 stars"></label>
<input type="radio" id="star3" name="rating" value="3" autocomplete="off" /><label class="full" for="star3" title="Meh - 3 stars"></label>
<input type="radio" id="star2" name="rating" value="2" autocomplete="off" /><label class="full" for="star2" title="Kinda bad - 2 stars"></label>
<input type="radio" id="star1" name="rating" value="1" autocomplete="off" /><label class="full" for="star1" title="Sucks big time - 1 star"></label>
</fieldset>
</div>
<div class="row">
<div class="col-lg-push-3 col-lg-6">
<div id="infoError2" style="width:100%;text-align:center; margin-right:50px !important; padding-right:45px;" class="alert"></div>
</div>
</div>
@* 0 - User watchlist // *@
<br>
<button data-remodal-action="cancel" class="remodal-cancel" id="cancelButton">Cancel</button>
<button class="remodal-confirm btnSaveWatchlist">Save</button>
</div>
</div>
然后,一旦我调用要执行的弹出窗口,如下所示:
$(document).on("click", ".btnWatchList", function (e) {
$("#popap")[0].click();
});
一旦这个事件完成,我注意到它会在我所在的 URL 中添加一个#modal(我不希望这种情况发生)。
触发事件后,我有一个如下所示的网址:
example.com?Ids=12312312412&Date=30#modal
但网址应保持如下:
example.com?Ids=12312312412&Date=30
有什么办法可以防止这种情况发生(这样一旦弹出窗口出现,#modal 部分就不会添加到 url 中)?
解决方案
you can also as @charlietfl suggested use the method given to you by the libary:
<a data-remodal-target="modal" id="popap" style="display:none;" href="#">Call the modal with data-remodal-id="modal"</a>
推荐阅读
- java - 用于检查可用类的 HTMLunit 帮助脚本
- modeling - OpenModelica (v1.13.0):FMU 导出损坏 - static.log:没有这样的文件或目录
- sql - 以 JSON 格式发送数据时,日期更改为前一天
- html - 通过使用 display: table-cell 用于表格行,display:block 用于 td 表格不起作用
- python - 使用 XGBoost 进行超参数网格搜索 - 评分函数与评估指标
- android - Android BottomsheetFragment Viewpager Fragment 没有视图
- php - 带有 PHP 解析器的 PSR-2 PrettyPrinter
- grafana - 我可以在 Grafana Graph Metrics 中使用数学方程式吗?
- java - 通过 POSIX AIO 或 Java 中的 Windows 重叠 IO 进行异步文件 I/O
- angular - Angular 中的 Git 工作流 npm 依赖项版本控制