javascript - Graceful degradation with Dijit -


i've been dojo (core) user few years now. building own widgets atop dojo space; neglecting dijit , dojox. working in own world. had it's advantages, kept having feeling i'm reinventing wheel while building yet tabbed panel, carousel or dialog box. i've decided use dijit.

with own widgets, i've set basic rules:

  1. a widget must degrade gracefully [when no js loaded] accessibility , seo
  2. there should no redraws after js loaded (which included on page after html, before body end-tag)
  3. no inline js (scripts must separate html)

problem:

dijit has 2 ways of being instantiated: declaratively , programmatically. either way seems break 1 of rules.

a. declarative instantiation:

looks either like:

<div dojotype="myfirstwidget">   <ul>     <li dojoattachpoint="counter">0</li>     <li><a dojoattachevent="_updatecounter" href="#">update</a></li>   </ul>    <script type="dojo/connect" event="onclick" args="evt">     console.log("this execute after of button dijit's onclick method has been called.");   </script> </div> 

as can see, breaks 3rd rule (no inline js).

b. programmatic instantiation:

dojo.require("dijit._widget"); dojo.require("dijit._templated");  dojo.declare("myfirstwidget", [dijit._widget, dijit._templated], {   templatestring: "<div class='awesome'>0</div>",    postcreate: function() {     console.log("postcreate");   } });  (new myfirstwidget()).placeat(dojo.body()); 

and way, rules 1 & 2 broken. (1) no accessibility or seo value (2) once template set, browser need redraw entire page.

question: possible (and practical) use dijit, , still follow rules?

yes, both possible , practical. however, rule #2 makes pretty difficult use pre-built dijits out of box since designed attach node , rebuild "dojo style". around styling node final result - may seem more trouble it's worth, way follow rule , still use of necessary compnents (that hard yourself) filteringselect.

mainly because of #2, recommend not use *dijit._templated*. use *dijit._widget*, , instead of having internal html, attach existing html in document.

maybe can bend #2, , allow modifed , restyled, not changes dom looks search engine or speech reader.

i never #3 myself, shouldn't hard.

for #1 depends on widget. can use standard browser select , upgrade dojo filteringselect.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -