简体   繁体   中英

Open modal bootstrap after filtering data

Story:

User enter data in a search field to find a client, it filters with ajax and lists in a table the results, If there is no results or phone number was not found. And number has more / or 7 digits: I open a modal, it works, but after it loads, if I type one or two more digits, it validates again, and is passing to the condition but the modal is not opening.I need to open it from php,the code I am using after the search is:

 <?php

     $isPhone = $this->isPhone;
     $strPhone = $this->strPhone;
     $strPhoneCount = strlen($strPhone);

     if(!$isPhone && $strPhoneCount >= 7 ){

        echo '<script type="text/javascript" language="javascript">';
        echo '$(document).ready(function(){';
        echo '$( "#dialog" ).modal("show");';
        echo '});';
        echo '</script>';

     }
    ?>

This happens because document ready event is triggered already. Just remove it from your code:

 if(!$isTel && $strTelCount >= 7 ){

    echo '<script type="text/javascript" language="javascript">';
    echo '$( "#dialog" ).modal("show");';
    echo '</script>';

 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM