Uiji.js is jQuery in reverse
aakilfernandes.com
aakilfernandes.com
The way you separate out logic from presentation in html ( proponents of unobtrusive js?) you SHOULD separate out html from js. Or it starts becoming a mess. Please dont make writing html in js easy because stupid ppl will use it and start making our lives harder.
$('#objectWorld .output').uiji({tag:'p','class':'greeting',html:'Hello Object World!'})
Alternatively, they could be using CoffeeScript where this is done for them automatically.I've never used it, any feedback on their syntax? I was planning on using a `space` instead of a `>` when I do inline hierarchy.
Also, what is zero padding? (`li.item$$$`)
edit: What is the purpose of zero padding?
001
002
010
022
Instead of:
1
10
2
22
If you think you might have a thousand items, you'd probably zero pad by 3 digits.
0001
0010
0100
1000
1001
Edit: of course, one area you're guaranteed to have trouble with numerical sorting is when your number is prefixed by a letter. Zero-padding mitigates that problem: M001, M002, M020, M023.
Stick to ">". That's the standard CSS for indicating a child element.
e.g. "div.myclass > h1" indicates a div with class "myclass" and a child h1 element. In zen, it outputs:
<div class="myclass">
<h1></h1>
</div>
http://www.w3.org/TR/CSS2/selector.html#pattern-matching`.uiji('p.greeting.earthling"Hello World!"')
1) The client side knows more about the client (screen width, device, scroll position) 2) Save yourself an AJAX call 3) Make your code more modular by templating jQuery and HTML at the same time. I plan on writing a whole blog post about this, but currently writing web apps seems to follow 1)Create DOM, 2) find relevant DOM with jQuery, 3) apply jQuery. This will combine steps 1 and 3 into the same template, and make 2 unnecessary.
$("<p>",{"class":"gretting",html:"Hellow World"}).appendTo("#helloWorld .output")
And you can also create hierarchy $("<p>",{"class":"gretting",html:
$("<a>",{href:"#",html:
$("<h1>",{html:"Hello World"})
})
}).appendTo("body")
Which looks disgusting but that is why template engines exist. $("<p>")
.addClass("greeting")
.html("Hello World")
.appendTo("#helloWorld .output")
And your second example: $("<p>")
.addClass("greeting")
.append(
$("<span>")
.html("Hello ")
.append(
$("<a>")
.prop("href", "google.com")
.html("World")
)
)
.appendTo("body");
It's just as verbose but much more readable.