I have been working on getting infowindows on my cartodb layers, but i am not sure what I am doing wrong as I want the infowindows to automatically close on feature out and only pop up when featurein or on hover regardless of the sublayer. A simple scaled down approach is as shown here. http://bl.ocks.org/jmwenda/b472b0a932fc5b895a5e59dadac18192. I have tried other methods such as shown with very little success. Any pointers on what I going on here or how to trigger the infowindow to automatically close?
cartodb.createLayer(map, markersLayerSource)
.addTo(map)
.done(function(layer) {
var publishedLayer = layer.getSubLayer(0);
publishedLayer.setInteraction(true);
var infowindow = publishedLayer.infowindow;
cdb.vis.Vis.addInfowindow(map, publishedLayer,['cartodb_id','cdb_list'],{triggerEvent: 'featureOver'});
publishedLayer.on('featureOver', function (e, latlng, pos, data, layer) {
//$(document).bind('mousemove', event);
$('.cartodb-popup').show();
//infowindow.set('visibility', true);
});
publishedLayer.on('featureOut', function (e, latlng, pos, data, layer) {
$('.cartodb-popup').hide();
//$(document).unbind('mousemove', event, false);
//infowindow.set('visibility', false);
});
});