lcdsantos / lcdsantos/jQuery-Selectric

Second event it's not loading in Mobile

Open
#245 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
715
Forks
149
PR merge metrics
No merged PRs in 30d

Description

I have a project where i use Selectric.

My first event works, but for the second one, there is nothing that makes it work. It's like the disableOnMobile:false configuration was not being loaded.

Here is how it looks:

var map;
var markers = [];

function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
        center: {
            lat: -25.72289,
            lng: 27.85378
        },
        zoom: 4
    });
    jQuery.each(stores, function(index, val) {
        var lat = val.Latitude.replace(",", ".");
        var lng = val.Longitude.replace(",", ".");
        var myLatlng = new google.maps.LatLng(lat, lng);
        var marker = new google.maps.Marker({
            position: myLatlng,
            title: val.Name,
            map: map,
        });
        var contentString = '<div id="content">' + '<div id="siteNotice">' + '</div>' + '<h2 id="firstHeading" class="firstHeading">' + val.Name + '</h2><p>' + val.Address1+" " +val.Address2+", <br>"+val.Address3+"<strong>"+val.City+","+val.PostalCode+"</strong>"+'</p></div>';
        var infowindow = new google.maps.InfoWindow({
            content: contentString
        });
        marker.addListener('click', function() {
            infowindow.open(map, marker);
        });
        markers.push(marker);
    });
    var markerCluster = new MarkerClusterer(map, markers, {
        imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'
    });
    jQuery('#region').selectric({
        disableOnMobile: false,
        nativeOnMobile: false
    });
    jQuery('#region').on('selectric-select', function(event, element, selectric) {
        jQuery('#stores').find('option').remove().end().append('<option value="999999">Select One</option>').val('whatever');
        jQuery.each(stores, function(index, val) {
            if (val.City == jQuery(element).val()) {
                console.log(val.City + "   " + jQuery(element).val());
                jQuery('#stores').append('<option value="' + index + '">' + val.Name + '</option>');
            }
        });
        jQuery('#stores').selectric('destroy');
        jQuery('#stores').selectric('init');
    });
    
    jQuery('#stores').selectric({
        disableOnMobile: false,
        nativeOnMobile: false
    });
    
    jQuery('#stores').on('selectric-select', function(event, element, selectric) {
        var lat = stores[jQuery(element).val()].Latitude.replace(",", ".");
        var lng = stores[jQuery(element).val()].Longitude.replace(",", ".");
        var myLatlng = new google.maps.LatLng(lat, lng);
        map.panTo(myLatlng);
        map.setZoom(20);
    });
}

I'm creating a personalized map with different markers. Once the person selects the filters, a new map should load showing the location of the filtered Store.

The second event, the one that loads the new map showing the filtered result, is the one that's not working on mobile.

Thanks in advance

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the mobile flow described with the #region and #stores Selectric instances, including the selectric-select handler and the destroy/init calls. Start by tracing those entry points in the Selectric source and verify whether the second control remains interactive after the filtered store options are replaced. Done means both selects respond on mobile and the filtered store selection updates the map.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.