I have a plugin where I am trying to re-initialize the javascript events after the ajax call. After the done method, all the events are lost.
I am trying to re-initialize the init method.
function Plugin(element, options) {
this.el = element;
this.$el = $(element);
this.settings = $.extend({}, defaults, options);
this._name = pluginName;
this.ns = '.myPluginName';
this.init();
}
Plugin.prototype = {
init: function();
var bind = this;
var somelink = bind.$el.find('.mylink');
var functionstartshere = function(){
// all the function starts here
//after the ajax call the new page looses all the event handlers
var jqxhr = $.ajax( "example.php" )
.done(function() {
//adding my function here
//how do i re-initialize the events
//how do I call the init/ functionstartshere to put the events back
})
.fail(function() {
alert( "error" );
})
}
some.on("click", functonstartshere);