Hi,
I'm creating a graph using flot javascript library. I have enabled clickable event and the div is binded to plotclick event. So, when a datapoint is clicked, an ajax call is made and the result is used to replace the current div. After this i need to bind the div to a new event.
I tried to call bind, but it is still bound to old callback. When i call unbind and bind, the new callback is not called.
var handleTeacherClick = function( event, pos, item ) {
if( typeof item != "undefined" && item ) {
var user_id = jQuery( 'input[name="id' + item.datapoint[0] + '"]' ).val();
jQuery.ajax({
type: 'POST',
url: BASEPATH + 'index.php/ajax/home/latest',
data: { "user_id": user_id },
dataType: 'json',
success: function ( result ) {
jQuery.plot(jQuery('#stats_prog'),
result.progress_data, result.progress_options);
jQuery.plot(jQuery('#stats_perf'),
result.performance_data, result.performance_options);
jQuery('.stats_title').
html('<span class="stats_title">'+
' >> Chapter '+Math.ceil(item.datapoint[0])+'</span>');
jQuery('#stats_prog')./*unbind("plotclick").*/
bind('plotclick', statClickHandler );
jQuery('#stats_perf')./*unbind("plotclick"). */
bind( 'plotclick', statClickHandler );
},
});
}
}