example11b_simple_events_w_render - add simple event callbacks (onclick, onmouseover, onmouseout) using _render



show FuncyTag html string output

show Javascript source code

To Notice: You may find there is common variables or code to use among the events you add to an "on...". Any funcyTag propert that begins with an underscore (_) will not be treated as an attribute or an event, so you can put your own data and methods there.

In this example there are two methods that will re-render the code for an element, and so a "_render" method is added that those other two event handlers may call:
oninit: function(elem) {
  this._render(elem);
},
onclick: function(elem,evt) {
  this._clicked++;
  this._render(elem);
},
_render: function(elem) {
  elem.innerHTML = p('box ' + this._idx) + p(this._clicked + ' clicks');
}
Note, especially, this first example that uses the "oninit" method, which is not a standard DOM event callback. You can use "oninit" for code to be executed once the first time this instance of a funcyTag is rendered.
next: example12_funcystyle_intro top: all js examples