Is Sizzle now oficially built-into the Smugmug JS?
jfriend
Registered Users Posts: 8,097 Major grins
I see that Sizzle for CSS3 selector DOM searches is now in the Smugmug JS. Can we officially use it in our own JS like we use YUI and expect it to always be available?
--John
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
0
Comments
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
John, I've no idea what this is but I'll ask the Sorcerers. You know I'm only an email away, sorry nobody replied.
Portfolio • Workshops • Facebook • Twitter
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Stay tuned, John.
Portfolio • Workshops • Facebook • Twitter
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Portfolio • Workshops • Facebook • Twitter
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
I can select elements and style or change them using JS, using any of the selectors in CSS3.
And the advantage is?
I can do styling with full CSS3 support even if the browser doesn't support CSS3... at the cost of writing JS instead of CSS rules.
I can dynamically modify the DOM based on CSS3 selectors... something I can't do with CSS.
Thanks,
http://www.danalphotos.com
http://www.pluralsight.com
http://twitter.com/d114
var links = Sizzle("#navcontainer a");
This was all doable before - it would have just taken more lines of code to do it. So Sizzle just saves you time and code.
Once you've found those elements in the DOM, you can do anything you would have normally done in the javascript, remove them, modify them, add to them, etc... Sizzle doesn't change what you can/can't do to them - it just makes it easier to find them in the DOM because you get all the goodness of CSS3 selector logic compared to the relatively few javascript functions for looking at the DOM.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
In poking at it I think I missing something about the object model or maybe just plain messing up.
The Sizzle api says it returns an array of DOMElement's. I'm not familiar with DOMElement's. I am familiar with the W3 DOM and HTMLElement's and Node's and such but when I try something like this it doesn't seem to work, i.e. the footer text is not affected.
In the Footer I put
<div style="font-size:20;color=green;">[<div class="myFooter"></div>]</div>
in the bottom JS I put
var eles = Sizzle(".myFooter");
for(var i = 0; i < eles.length; i++)
{
eles.innerHTML = "<b>some stuff</b>";
}
The [] appear in the footer, but not the text the JS was supposed to add.
http://www.danalphotos.com/Other/Quabbin-10-25-09/10087243_sPx5G#693362653_WcCdo
I'm guessing I am missunderstanding what a DOMElement is.
http://www.danalphotos.com
http://www.pluralsight.com
http://twitter.com/d114
The code should generally work, but the way you have it called in your page won't work because of the timing of things. Your code was executing before the whole page had loaded and, more specifically, before the HTML that had .myFooter in it had loaded.
Try this:
FYI, this HTML:
should be:
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
I can see where YE and YA and such are set up as various YAHOO. objects in smugmug_core. Can you give me a pointer to the documentation for these functions?
http://www.danalphotos.com
http://www.pluralsight.com
http://twitter.com/d114
http://www.danalphotos.com
http://www.pluralsight.com
http://twitter.com/d114