jquery colorbox 'inline' modal opening for first time only

594 views Asked by At

I am using jquery colorbox 'inline'. It is opening first time from a specific link.

<a class="addFile inline"  href="#inline_content">
     <img src="img/nav-icons/icon_plis.png" alt="">
     Add File
</a>

with the jquery written over

$(".inline").colorbox({inline:true, width:"40%",href:"#inline_content"});

but when I am trying to open another inline content (#inline_content2) from different link(s) on the same page, the previous inline content (#inline_content) is opening. Please help me to resolve the issue. -thanks

1

There are 1 answers

1
Mohamed-Yousef On

in click event for

$('.inline').on('click',function(e){
    e.preventDefault();
    $(this).colorbox({inline:true, width:"40%",href:$(this).attr("href")});
});

or you can use .each();

$('.inline').each(function(){
    $(this).colorbox({inline:true, width:"40%",href:$(this).attr("href")});
});

if both of them not work make a specific class for each anchor

$(".inline").colorbox({inline:true, width:"40%",href:"#inline_content"});
$(".inline1").colorbox({inline:true, width:"40%",href:"#inline_content1"});
$(".inline2").colorbox({inline:true, width:"40%",href:"#inline_content2"});
... etc