Help with trigerring events and showing results in sidebar tabs

43 views
Skip to first unread message

jpardila

unread,
Sep 2, 2016, 11:51:21 PM9/2/16
to Leaflet
Hi All,

I am struggling at the moment with a simple  functionality I want to add to a map using Leaflet and the sidebar plugin. When I click on a feature I want to trigger two functions, which would change the content dynamically of tab A and  tab B. I want to keep them as separate functions. 
I somehow cannot get both functions to execute, or at least I see only results for one of them.

To illustrate better see the fiddle code. Click on the blue polygon, then see the tabs and the only html that changed is that of the #profile page. The #home tab does not change. 


Could anyone please help me figure this!

k_man_au

unread,
Sep 8, 2016, 2:53:22 AM9/8/16
to Leaflet
Try this... btw I think your ID tags are in the wrong spots... 

function onClick(e){
var layer = e.target;
plot_percentage_A(layer.feature.properties);
plot_percentage_B(layer.feature.properties);
  map.fitBounds(e.target.getBounds());
}
function plot_percentage_A(props) {
      $('#profile').html('Something Here');        
}

function plot_percentage_B(props) {
      $('#messages').html('Something else here');        

jpardila

unread,
Sep 11, 2016, 1:13:24 AM9/11/16
to Leaflet

Great! Thanks a lot.  I tried your suggestion and it works great. Much simpler than what I was trying to do. 
This is the updated code
Reply all
Reply to author
Forward
0 new messages