enyo / opentip

Opentip is an open source javascript tooltip based on the protoype framework.
http://www.opentip.org
1.25k stars 401 forks source link

ajax response processing #52

Closed ozyn closed 11 years ago

ozyn commented 11 years ago

I want to use openTip in conjunction with Ajax. My ajax call returns a JSON object that I format on the client. I see in the code that the ajax call directly sets the content in the opentip popup (line 1195): onSuccess: function(responseText) { //…. return _this.setContent(responseText);

What I want would be more like onSuccess: function(responseText) { //…. return _this.setContent(myCallBackFunction(responseText));

Also, I’d want to pass other parameters to the Ajax call.

Are those possible?

enyo commented 11 years ago

Mh.. there's no built in function for that. But you can "enhance" Opentip for that.

Example:

var originalSetContentFunction = Opentip.prototype.setContent;
Opentip.prototype.setContent = function(content) {
  // Do anything you want with the content, or call callbackFunctions.

  // Invoke the original setContent() function which will make sure to update the content and reposition
  // opentip properly.
  originalSetContentFunction.call(this, content);
};

Hope that helps. Cheers