jquery - On Chrome and Opera, mousedown action on a selector control causes mousedown and mouseup events to fire -
i’m developing javascript-based web app displays various times series of weather data on tab. time series displayed on tab controlled select control id = tempvarselect. changes tempvarselect control meant execute changetempdisplay(), hides , shows time series graph on tab. changetempdisplay() function bound changes in tempvarselect via jquery mouseup event:
$("#tempvarselect").mouseup(function( ){ changetempdisplay(); }); function changetempdisplay(){ var tempvar = number(document.getelementbyid("tempvarselect").value); switch (tempvar) { case 0: console.log(" temp_display = " + tempvar); $("#tmaxgraph").show(); $("#tmaxlabels").show(); $("#tmingraph").hide(); $("#tminlabels").hide(); plottmax(); break; case 1: console.log(" temp_display = " + tempvar); $("#tmaxgraph").hide(); $("#tmaxlabels").hide(); $("#tmingraph").show(); $("#tminlabels").show(); plottmin(); break; } }
this works safari , firefox, i.e. mousedown-mousemove-mouseup sequence on tempvarselect selector causes graph type selected on mouseup display properly.
but on chrome , opera changetempdisplay appears fire on mousedown, causing current time series display re-plotted , tempvar number selected on mousedown echoed console.log. result, there no change display. mousemove , mouseup causes tempvarselect selector assign correct tempvar value , highlight correct selected variable on mouseup, because changetempdisplay fires on mousedown, there no change time series display. when mousedown on tempvarselect after that, changetempdisplay fires changed value of tempvar, , display changes new time series should.
by conducting simplified test echoes mousedown , mouseup times console.log, i.e.
var time0 = new date().gettime();
$("#tempvarselect").bind("mouseup",function( ){ time = new date().gettime() - time0; console.log(" tempvarselect mouseup @ t = " + time); }); $("#tempvarselect").bind("mousedown",function( ){ time = new date().gettime() - time0; console.log(" tempvarselect mousedown @ t = " + time); });
i’ve found happening mousedown action triggers mousedown-mouseup sequence in chrome, mousedown in safari , firefox. result, changetempdisplay() fires on mousedown action in chrome.
i’ve checked out similar problems (e.g., jquery mouseup not being detected correctly ), don’t seem apply i’m seeing.
does have idea why occur?
Comments
Post a Comment