A
A
Aleksander9112015-12-23 05:21:32
JavaScript
Aleksander911, 2015-12-23 05:21:32

How to disable js execution with saving in cookies?

Good day everyone. There is js that sends an event when hovering over a block in a Google map:

$(".appartment").each(function(){
        var ap_id = $(this).attr("ap_id");				
        $(this).on("mouseenter", function() {					
          google.maps.event.trigger(Marker[ap_id], "click");
        });						
        });

Tell me how to implement and is it possible to do it at all, so that when the checkbox is set, the execution of this script is disabled and the cookie is written so that the script is not executed at the next boot and the reverse action is to enable script execution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2015-12-23
@Aleksander911

$('input[type="checkbox"]').on('change', function() { 
    if ($(this).prop('checked')) { 
        $(".appartment").off('mouseenter');
        $.cookie('map-trigger-status', 'off'); // Библиотека для работы с cookies: https://github.com/carhartl/jquery-cookie
    }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question