-
Notifications
You must be signed in to change notification settings - Fork 35
Home
Maksim Chemerisuk edited this page Feb 5, 2015
·
10 revisions
There are several frequently asked questions about better-dom:
Native element is stored in property [0]
:
var body = DOM.find("body");
body[0].addEventListener("click", function() {
// handle global click using native style
}, false);
Sure. Note: you don't need to wrap iterated elements (with something like $
in jQuery):
var links = DOM.findAll("a");
_.find(links, function(el) {
return el.get("title") === "stop";
});
The event object is not accessible directly, but you can read its properties by specifying an extra array argument in event handlers:
input.on("keydown", ["which", "shiftKey"], (which, shiftKey) {
// use which to determine key code, and shiftKey
// to check if the shift key was pressed
});
Sure, just use method DOM.constructor
:
// a native bridge example
var foo = DOM.constructor(document.getElementById("foo"));
// a jQuery bridge example
var foo = DOM.constructor($("#foo")[0]);