Jquery Ajax with Leaflet and MarkerCluster Errors out -


i have application loading markers dynamically looping through dataset.

for (var = 0; < data.length; i++) {                 var plateno = data[i].plate_number;                 var permitno = data[i].permitinfoid;                 var popup = '<h5>eps</h5>' + 'plate:' + plateno + '<br/>' +                     ' permit: <a class=\'link\'  href=' + url + '>' + permitno + '</a>' +                      '<p style=\"color:blue\">' + '' + '<a class=\'link\'  href=' + url + '>' +                      'import' + '</a>' + '<br/>' + '<a class=\'link\'  href=' + url + '>' +                      'duplicate' + '</a>' + '<br/>' + '<a class=\'link\'  href=' + url + '>' +                      'removed' + '</a>' + '<br/>' + '</p>';                  var m = l.marker([data[i].ref_latitude, data[i].ref_longitude], { icon: epsiconr, draggable: 'true' })                                     .bindpopup(popup);                 markerclusters.addlayer(m);                  }                 map.addlayer(markerclusters);             map.invalidatesize(false); 

i attaching event handler each of items class 'link' this:

  map.on('popupopen', function () {             $('.link').click(function (e) {                 createdialog();             });         }); 

i ajax loading different page in createdialog method this:

 function createdialog() {              $("#testpara").slidetoggle("slow");         $.ajax({             datatype: 'html',             url: '/home/updateinventory',             success: function (data) {                 $('#testpara').html(data);             }         }); 

}

the markers cluster fine , clicking on popups ajax loads div fine. once ajax load done if try zoom in or out of map or drag map around error cannot read property 'lat' of undefined

map freezes after that. have been stuck on entire day , appreciate or input.

this fiddle shows issue, when click on link console shows error

http://jsfiddle.net/pk9vbvs4/

thanks

it looks me trying load page has scripts collide current page scripts (and possibly document id's well). @ least in jsfiddle, try load same page (using url: '/'), breaks javascript.

all scripts loaded twice, , initialization code run again on variables not re-initialized, weird things happen.

demo of loading without script inside: http://jsfiddle.net/pk9vbvs4/1/ still runs fine.

since not have detail target page, cannot tell sure root cause issue.


Comments

Popular posts from this blog

r - how do you merge two data frames the best way? -

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -

php - mySQL problems with this code? -