“Always on ” jquery command

前端 未结 2 1164
北恋
北恋 2021-01-29 02:16

recently i\'m working on a project to make an interactive directory map for a mall without using flash, because they need to access from mobile devices.

but i have issu

相关标签:
2条回答
  • 2021-01-29 03:04

    The problem is you don't turn off the highlight for currently selected area when clicking on another.

    Place this:

    $('.selected').data('maphilight', {alwaysOn: false}).trigger('alwaysOn.maphilight');
    

    in your salhia.js, in the .mapclick click handler:

    $('.mapclick').click(function(){
        $('.selected').data('maphilight', {alwaysOn: false}).trigger('alwaysOn.maphilight');
    
        $('.mapclick').removeClass('selected');
        $(this).addClass('selected');
    
        var shop = '.shopdetails#' + $(this).attr('shop');
        var htmlCode = $(shop).html();
    
        $('.shopinfo').fadeOut(500, function(){
            $('.shopinfo .shopdetails').html(htmlCode);
            $('.shopinfo').fadeIn(500);
        });
    });
    
    0 讨论(0)
  • 2021-01-29 03:12

    Changed a bit the code shown on previous answer so it is more generic:

    // Init
    $('.map').maphilight({
           stroke: false,               
    }); 
    
    // Reset all map
    
    $('.selected').data('maphilight', {alwaysOn:false}).trigger('alwaysOn.maphilight'); 
    
    $('area').click(function(){    
        // Reset all areas with class 'selected'
        $('.selected').data('maphilight', {alwaysOn: false}).trigger('alwaysOn.maphilight');
        // Remove class selected
        $('area').removeClass('selected');
        // select and highlight this area
        $(this).addClass('selected');
        $(this).data('maphilight', {alwaysOn: true}).trigger('alwaysOn.maphilight');
    });
    
    0 讨论(0)
提交回复
热议问题