Skip to content

Conversation

@volpino
Copy link

@volpino volpino commented Dec 21, 2011

hi!
I added some changes to your code because i needed a callback for the sortable list. I use your multiselect as a layer selector for OpenLayers (unfortunately i don't have an online public demo). When i sort the list i want the layers on the map to sort too.

So i use this code to create the multiselect:

    $(".multiselect").multiselect({                                            
      sortable: 'left',                                                        
      sortableUpdate:                                                          
        function(event, ui, sortable) {                                        
          var layer_list = sortable.sortable("toArray");                       
          var layer_id = ui.item.attr("id");                                   
          var layer = map.getLayersBy("id", layer_id)[0];                      
          if (!(layer.isBaseLayer || layer_id.search("OSM") != -1)) {          
            var layer_pos = layer_list.length - 1 - layer_list.indexOf(layer_id);
            if (layer_pos != 0) {                                              
              console.log("moving " + layer_id + " to " + layer_pos);          
              map.setLayerIndex(layer, layer_pos);                             
              return;                                                          
            }                                                                  
          }                                                                    
          sortable.sortable('cancel');                                         
        },                                                                     
      selected:                                                                
        function(event, ui) {                                                  
          map.getLayersByName($(ui.option).val())[0].setVisibility(true);   
        },                                                                     
      deselected:                                                              
        function(event, ui) {                                                  
          map.getLayersByName($(ui.option).val())[0].setVisibility(false);  
        }                                                                      
    });

I removed some trailing whitespaces, and an unused css class that was messing everything up because it is defined in the twitter bootstrap css (which i'm using for the whole webpage style).

@Prasanna79
Copy link

The 'actions' class added in js messes things up with Twitter Bootstrap. Looks like it should be 'action' according to the css.

@volpino
Copy link
Author

volpino commented Mar 9, 2012

Yes, it's what my patch is about.
You can use my fork in the meanwhile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants