nathan-alden-sr / dom-view-js Goto Github PK
View Code? Open in Web Editor NEWRepresents the DOM as hierarchical jQuery objects
License: Other
Represents the DOM as hierarchical jQuery objects
License: Other
Because JavaScript's property iteration is non-deterministic, any code that relies on context parameters is not guaranteed to work. For example, selector properties with function values and jQuery event property function values can both receive context, which is the current state of the underlying object. However, the current state is non-deterministic because of the JavaScript specification. Some browsers may retain the order as specified in code, but that behavior cannot be relied upon.
http://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order
A developer should be able to return false
in init
function in order to tell DOMView to ignore that particular selector object. This is useful for optionally adding properties to the view object based on a flag.
Consider the following code:
var view = DomView({
selector: ".container",
foo: function (view) {
view.bar();
},
bar: function (view) {
// view is undefined
}
});
When foo
calls bar
, bar
is not being provided with the view object.
Custom functions must be evaluated at least once before the DomView
function returns. This is because they might create objects that themselves hook to the DOM (e.g., jQuery plugins).
On the following sample:
var view = DomView({
selector: ".container",
button: {
selector: "input[type='button']",
disable: function (view) {
this.prop("disabled", true);
this.attr("value", view.message()); // Calls the wrapper function, not the real function defined below
}
},
message: function () { // Only called once with its return value cached for subsequent wrapper function evaluations
return "Disabled!";
}
});
I'm seeing disable and message get executed when the button is "inited". Is this intended behavior?
This is problematic on cases where you're trying to attache a "disable" function to your button while a form is being submitted.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.