1

IziModal is beautiful but Jquery selectors cannot see or find the modal elements it hides. So this code: var nextmodal = $(this).next('.izra'); $(nextmodal).iziModal('open'); , which can see any div hidden by display:none, can find any element EXCEPT divs hidden by Izimodal.

https://jsfiddle.net/zmbth7u9/4/ (Stack code snippet below) Izimodal can find its own hidden div with class .izra but no Jquery selector can?

I've tried everything including div: $(this).next($(":hidden:first")); console.log($(hiddenstuff))

The above code SKIPS OVER the Izimodal hidden div and finds the second! I need to activate modals with generic classes repeated throughout documents for footnotes, saving code, markup and time.

Any idea how I can get Jquery selectors to find the div with the .izra class so I can act on it?

Since we cannot find siblings because IziModal hides them beyond reach, perhaps modal divs should begin without the .izra class (set to display:none by css) and dynamically add the .izra modal class upon hitting the click trigger? We could find the divs first with next(), then add the izra class, or would that put us back at square one? Thank you!

https://jsfiddle.net/zmbth7u9/4/ The modal and finding divs in this fiddle works, and shows the lines that inexplicably don't work.

//How things should Work generically
$('.generictrigger').click(function () {
    var nextmodal = $(this).next('.genericmodal');
    $(nextmodal).modal('show');
});

//IziModal Initialize and fire on open
$(function () {
    $(".izra").iziModal();
    $('.izra').iziModal('open'); // This works!
});

//Proof hidden divs easily found when NOT hidden by IziModal
$(".trigger2").click(function () {
    var hiddenstuff = $(this).next($(":hidden:first")); // This works!
    console.log($(hiddenstuff))
});

//Proof IziModal divs cannot be found by Jquery selectors
$(document).on('click', '.trigger', function (event) {
    event.preventDefault();
    //  $('.izra').iziModal('open'); // THIS WORKS!
    var nextmodal = $(this).next('.izra'); // Should work but does not
    console.log($(nextmodal));
    $(nextmodal).modal('open'); // Should work but does not <<<<<<
});
 .hidden { display: none; }
                .c1 { background-color:#33ccff; }
                .c2 { background-color:#ffff99; }
                .c3 { background-color:#80ff80; }
                
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js"></script>
   
<link href="https://cdnjs.cloudflare.com/ajax/libs/izimodal/1.5.1/css/iziModal.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/izimodal/1.5.1/js/iziModal.js"></script>


<!--  Finding divs hidden by IziModal Begin   -->
<!-- How things should generically work calling Next() -->
            <div class="containerdivforchildren">
                <div class="c1 generictrigger">Click for Generic Modal FOUND by NEXT Selector </div>
                <div class="genericmodal modal fade modal-body modal-content"><a title="Close"><i data-dismiss="modal" class="glyphicon glyphicon-remove icon-arrow-right pull-left"></i></a>Generic Bootstrap Modal</div>
            </div>
            
            <!--        This section proves any div can be found EXCEPT divs touched by IziModal -->

            <div class="modaltriggercontainer">
                <div class="trigger2 c3">Click to Log var hiddenstuff = $(this).next($(":hidden:first"));to console</div>
                <div class="trigger c2">Click to Open Izra (will fail but logs results of $(this).next() to console</div>
                <div class="izra">Unretrievable modal div when hidden by IziModal class</div>
                <!--Above DIV IS SKIPPED AND CANNOT BE FOUND!-->
                <div id="incognito" class="c1 oddlynamed hidden">hidden by style but found using $(this).next()</div>
            </div>
            <!--  Above div is the first div found by any selector looking for the .next()-->
Jonas
  • 121,568
  • 97
  • 310
  • 388
CodeNotes
  • 11
  • 2

0 Answers0