mardi 28 juin 2016

how to show other condition if we click on same button twice in jquery

guys can you help me how to show other condition, if we have clicked at the same button 2 times?

this is the first condition when i clicked a button, and i have success to show the condition, so there is no problem here :

if(unable == 4) {
        $("#formitem").submit(function () {
            $("#order_4").appendTo("body");
            var message = "<?=$message_change_location?>";
            var resotid = <?=$restaurant_info["restaurant_id"]?>;
            var restoname = "<?=$restaurant_info["restaurant_name"]?>";
            var restomenu = "<?=$restaurant_menu?>";
            var postal = "<?=$postal?>";
            var delivery_no = "<?=$delivery_no?>"
            jQuery.ajax({
                type: "GET",
                url: "/ajax/order_unable",
                dataType: 'html',
                data: {
                    message_change_location: message,
                    restid: resotid,
                    restname: restoname,
                    restmenu: restomenu,
                    postal: postal,
                    delivery_no: delivery_no,
                },
                success: function (res) {
                    $("#order_4_show").html(res);
                    $("#order_4").modal("show");
                }

            });
            return false;
        });

this the the view for order_unable

<div class="sub">
<div class="container">
    <div class="vendors-heading">
        <h1><?=$notification;?></h1>
    </div>
    <div class="col-md-2"></div>
    <div class="row">
    <div class="col-md-4">
        <a class="btn btn-primary  location-near-you-button" href="/restaurants/city/<?=$postal?>">
            <?=$this->lang->line('restaurants_restaurant_near_you')?>
        </a>
    </div>
        <a class="btn btn-primary  change-location-link change-btn" href="#" id="change_location_2">
            <?=$this->lang->line('restaurants_change_location')?>&nbsp;<i class="fa fa-angle-right"></i>
        </a>
</div>

<script>
$("#change_location_2").click(function () {
    $(".vendor-heading").hide();
    $(".location-header").hide();
    $("#second_notif").show();
    $("#order_4").modal("hide");
    return true;
    });
</script> //this is script is for the `unable_order`

the problem is if i have clicked change_location_2 in unable_order view, than if i click $("#formitem").submit(function () for the second times, i want to show the other condition.

I have tried this and there is nothing change :

}else if ($("#change_location_2") == true){
        $("#formitem").submit(function () {
            alert("sadf");
            $("#test").modal("show");
            return false;
        });

Guys can you help me how to do this?

Aucun commentaire:

Enregistrer un commentaire