Как мне запустить мод начальной загрузки с помощью строки, которая есть в скрипте? - PullRequest
0 голосов
/ 21 мая 2019

У меня есть средство выбора времени, после которого я хочу, чтобы появилось всплывающее окно с сообщением: «Время установлено на время x».Я хочу добиться этого, вызывая модальные после нажатия на набор.Это строка «set», которую можно увидеть в скрипте.Правильно ли я подхожу к этому вопросу?Или есть другой способ?

<div class="row menu_page">
    <div class="col s12 m3"></div>
    <div class="col s12 m6">
        <h3>Time Picker</h3>
        <form>
            <div class="input-field">
                <input type="text" id="time" class="timepicker" >
                <label for="time">Set time</label>
            </div>
        </form>
    </div>
    <p id="test"></p>
    <div class="col s12 m3"></div>

    <!-- Modal -->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    ...
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>

</div>
<script>
    const timer = $(".timepicker");
    M.Timepicker.init(timer,{
        showClearBtn:true,
        twelveHour: false,
        i18n:{
            clear: "remove",
            cancel: "cancel",
            done: "set",
        }
    });
    timer.on("change",function(e){
        console.log("init js");
        const now = new Date()
        now.setHours(time.M_Timepicker.hours)
        now.setMinutes(time.M_Timepicker.minutes)
        API.post("settings/time",{new_time: now.getTime()})
    });
    $( "#time" ).change(function() {
        console.log("time is set!");
        // $('#exampleModal').modal('options'); 


    });

</script> 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...