Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

jquery - How to associate an event with only one object? jqplot -


im using jqplot draw charts. great tool, lacks simple clickhandler option each chart.

its plugins highlighter, draggable , cursor register interest in capturing click/mouse-events jqplot canvas adding jqplot.eventlistenerhooks (eventlistenerhooks.push(['jqplotclick', callback]); example. or 'jqplotmousedown' or such available.

after making plot usual $.jqplot(target, data, options);

$.jqplot.eventlistenerhooks.push(['jqplotclick', myfunc]);

and sure enough myfunc gets called wherever click on plot, event, neighbour, datapos , gridpos. neighbour interesting, contains data point if there click on it. data need make popup close gridpos aditional information on datapoint.

but problem if have 2 charts on same page , want register different callbacks each jqplot. now, when register second myfunc2, clicks on second plot go through myfunc aswell!

do need make changes jqplot? directions, whatsoever?

thanks

this isn't well-documented, can find discussion here.

basically, need create event handlers chart before calling jqplot create actual chart. that, need this:

var handler = function(ev, gridpos, datapos, neighbor, plot) {     if (neighbor) {         alert('x:' + neighbor.data[0] + ' y:' + neighbor.data[1]);     } };  $.jqplot.eventlistenerhooks.push(['jqplotclick', handler]); 

that's simple event handler checks see if there's neighboring data point near clicked. see working example here: http://jsfiddle.net/andrewwhitaker/ptyfg/

update: if want listen events on plot, this:

var handler = function(ev, gridpos, datapos, neighbor, plot) {     if (plot.targetid === "#chartdiv") {         if (neighbor) {             alert('x:' + neighbor.data[0] + ' y:' + neighbor.data[1]);         }     }     else if (plot.targetid === "#chart2div") {         ....     }     // etc... }; 

where replace #chartdiv whatever id of chart want listen events is. example has been updated.

update 2: looks can use regular bind event plot events:

$("#chartdiv").bind("jqplotclick", function(ev, gridpos, datapos, neighbor) {     if (neighbor) {         alert('x:' + neighbor.data[0] + ' y:' + neighbor.data[1]);     } }); 

example using method, 2 charts:

http://jsfiddle.net/andrewwhitaker/ptyfg/5/

hope helps!


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -