3 ms·
Don't do this: var oldonload = window.onload; Try to avoid touching the global namespace. At most register one object in it: HelpBubble. Use callbacks for t
by IgorPartola 16y ago
Don't do this:
var oldonload = window.onload;
Try to avoid touching the global namespace. At most register one object in it: HelpBubble. Use callbacks for the init, open, close, and clicked events. Look at how jQuery does it.
These are too long:
HelpBubble.API.setText()
HelpBubble.API.setMenuStyle()
HelpBubble.API.setButtonStyle()
I would use:
HelpBubble.API.text()
HelpBubble.API.menuStyle()
HelpBubble.API.setButtonStyle()
Passing it nothing should return the current value (for the latter two it should return objects). Setting it should take either objects or strings.
Also, do you expect to only have one instance of these at a time? If not, your API might not work very well.
- dannyr 16y agoJQuery does the same. $("#element").html($("#element").html() + custom_html);
- IgorPartola 16y agoYes, and I very much like that API. It's concise which is a huge win when you have to read that code later.
- spicyj 16y agoCan't you just type $("#element").append(custom_html)?