单击时关闭弹出窗口
Close popin when click
我有这个小代码可以关闭 popin :
$('.interop-sidebar_right .icon-close').on('click', function () {
console.log("close");
var elem = $('.interop-sidebar_right');
elem.hide();
});
但这不起作用:(
这是我的全部文件:
(function ($, Drupal) {
$('document').ready(function(){
//Load default sidebar text
var entity_id = drupalSettings.interop.nid;
getSidebarRight(entity_id, 'text-1');
//SVG
$('.svg-text').on('click', function () {
var id = $(this).attr('rel');
getSidebarRight(entity_id, id);
// Précious line of code <3
$(this).addClass("svg-style").siblings("text.svg-text").removeClass("text svg-style");
$("#"+id).show().siblings(".right-sidebar").hide();
});
//Arbre decisionnel
$('#arbre-decisionnel-form input.form-radio').on('click', function () {
var id = $(this).attr('id');
var entity_id = $(this).val();
getSidebarRight(entity_id, id);
});
//Ajax get sidebar html
function getSidebarRight(entity_id, id) {
$.ajax({
url : '/asip_interop/getInfosServices/' + entity_id + '/' + id,
type : 'GET',
dataType : 'html',
success : function(html, status){
if(html.length > 0) {
$('.aside-home-bar .region-right-sidebar').html(html);
}
}
});
}
// Close Modale by clicking on the cross X
$('.interop-sidebar_right .icon-close').on('click', function () {
console.log("close");
var elem = $('.interop-sidebar_right');
elem.hide();
});
});
})
(jQuery, Drupal, drupalSettings);
还有 html :
<div class="interop-sidebar_right -2" id="styckyRightCol">
<h2> Informations services <span class="icon icon-close"> </span></h2>
<div class="region-right-sidebar_bloc-infos">
<span class="icon icon-info"></span>
<p>Cliquez sur le symbole pour faire apparaître des Informations et des liens. </p>
</div>
<div class="region-right-sidebar_body">
<h3>{{ titre }}</h3>
{{ body|replace_shortcode|replace_shortlink|raw }}
{% if links or docs %}
<div class="region-right-sidebar_links">
{% for link in links %}
<p class="icon-left icon-attach">
<a href="{{ link.url }}">{{ link.title }}</a>
</p>
{% endfor %}
{% for doc in docs %}
<p class="icon-left icon-download">
<a href="{{ file_url(doc.entity.field_me_document_file.entity.uri.value) }}" target="_blank">{% if doc.entity.field_me_document_title.value %} {{ doc.entity.field_me_document_title.value }} {% else %} {{ doc.entity.name.value }} {% endif %}</a>
</p>
{% endfor %}
</div>
{% endif %}
</div>
</div>
有什么帮助吗?
谢谢
试试这个它应该适合你
$(document).on('click','.interop-sidebar_right .icon-close', function () {
$('#styckyRightCol').hide();
});
我有这个小代码可以关闭 popin :
$('.interop-sidebar_right .icon-close').on('click', function () {
console.log("close");
var elem = $('.interop-sidebar_right');
elem.hide();
});
但这不起作用:(
这是我的全部文件:
(function ($, Drupal) {
$('document').ready(function(){
//Load default sidebar text
var entity_id = drupalSettings.interop.nid;
getSidebarRight(entity_id, 'text-1');
//SVG
$('.svg-text').on('click', function () {
var id = $(this).attr('rel');
getSidebarRight(entity_id, id);
// Précious line of code <3
$(this).addClass("svg-style").siblings("text.svg-text").removeClass("text svg-style");
$("#"+id).show().siblings(".right-sidebar").hide();
});
//Arbre decisionnel
$('#arbre-decisionnel-form input.form-radio').on('click', function () {
var id = $(this).attr('id');
var entity_id = $(this).val();
getSidebarRight(entity_id, id);
});
//Ajax get sidebar html
function getSidebarRight(entity_id, id) {
$.ajax({
url : '/asip_interop/getInfosServices/' + entity_id + '/' + id,
type : 'GET',
dataType : 'html',
success : function(html, status){
if(html.length > 0) {
$('.aside-home-bar .region-right-sidebar').html(html);
}
}
});
}
// Close Modale by clicking on the cross X
$('.interop-sidebar_right .icon-close').on('click', function () {
console.log("close");
var elem = $('.interop-sidebar_right');
elem.hide();
});
});
})
(jQuery, Drupal, drupalSettings);
还有 html :
<div class="interop-sidebar_right -2" id="styckyRightCol">
<h2> Informations services <span class="icon icon-close"> </span></h2>
<div class="region-right-sidebar_bloc-infos">
<span class="icon icon-info"></span>
<p>Cliquez sur le symbole pour faire apparaître des Informations et des liens. </p>
</div>
<div class="region-right-sidebar_body">
<h3>{{ titre }}</h3>
{{ body|replace_shortcode|replace_shortlink|raw }}
{% if links or docs %}
<div class="region-right-sidebar_links">
{% for link in links %}
<p class="icon-left icon-attach">
<a href="{{ link.url }}">{{ link.title }}</a>
</p>
{% endfor %}
{% for doc in docs %}
<p class="icon-left icon-download">
<a href="{{ file_url(doc.entity.field_me_document_file.entity.uri.value) }}" target="_blank">{% if doc.entity.field_me_document_title.value %} {{ doc.entity.field_me_document_title.value }} {% else %} {{ doc.entity.name.value }} {% endif %}</a>
</p>
{% endfor %}
</div>
{% endif %}
</div>
</div>
有什么帮助吗?
谢谢
试试这个它应该适合你
$(document).on('click','.interop-sidebar_right .icon-close', function () {
$('#styckyRightCol').hide();
});