ramnathv/htmlwidgets — pull request #5 by jcheng5 (2014-07-25 17:15:42+00:00)
Title: Unify bindings

This is a proposal for unifying the little JavaScript snippet each widget author needs to include--rather than having one codepath for static rendering and one codepath for Shiny, you can use this simplified API to support both at once:

```r
HTMLWidgets.widget({
name: "knob",
initialize: function(el) {
$(el).knob();
},
renderValue: function(el, data) {
$(el).trigger("configure", data);
$(el).val(data.value).trigger("change");
}
});
```

Open questions/issue:

- [ ] If it's likely we'll have input bindings in the future, then perhaps `HTMLWidgets.widget` should be renamed `.outputWidget`, or something like `widgetType: "output"` or `output: true` should be required on the object.
- [ ] The `widgetOutput` function uses `widgetname_output` rather than just `widgetname`. I didn't include it in this PR but to get the knob example working, I had to change it to just `widgetname`. Maybe you can help me understand the indented semantics of `widget_div`/`widgetOutput`.