<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1930213017396645687</id><updated>2012-03-20T02:03:49.525-06:00</updated><category term='facebook'/><category term='google maps'/><category term='truism'/><category term='defaction'/><category term='errorstack'/><category term='statcounter'/><category term='YQL'/><category term='firebug'/><category term='brightkite'/><category term='events'/><category term='linkedin'/><category term='edoism'/><category term='seo'/><category term='crud'/><category term='webhooks'/><category term='jquery'/><category term='iphone'/><category term='kynetx'/><category term='annotation'/><category term='css'/><category term='geolocation'/><category term='push'/><category term='aculis'/><category term='XPath'/><category term='twilio'/><category term='online identity'/><category term='twitter'/><category term='bigohoo'/><category term='oauth'/><category term='social media'/><category term='blogger template'/><category term='webapp'/><category term='JSON'/><category term='widget'/><category term='foursquare'/><category term='safari'/><title type='text'>edoism</title><subtitle type='html'>truism of ed orcutt</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://edoism.orcutt.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/-/defaction'/><link rel='alternate' type='text/html' href='http://edoism.orcutt.org/search/label/defaction'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ed Orcutt</name><uri>http://www.blogger.com/profile/01072069799127687951</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_tXU2PrpKxHU/SuDD5YwomTI/AAAAAAAAAII/hCrRNUZWOto/S220/edo_transjpg.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1930213017396645687.post-2555855760959979376</id><published>2011-10-25T23:22:00.000-06:00</published><updated>2011-10-25T23:22:53.624-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='defaction'/><category scheme='http://www.blogger.com/atom/ns#' term='kynetx'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>CSS Inception with Kynetx</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-Dsb6t-9Myoc/TqeYX4JIEjI/AAAAAAAAAUI/NfpeRgrFPgc/s1600/CSS_Inception_300x250.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="166" src="http://3.bp.blogspot.com/-Dsb6t-9Myoc/TqeYX4JIEjI/AAAAAAAAAUI/NfpeRgrFPgc/s200/CSS_Inception_300x250.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;While developing an administrative interface for a web application I only wanted to load the CSS stylesheet for the administrative view when it was needed. KRL provides the ability to define &lt;a href="http://docs.kynetx.com/docs/Global#CSS"&gt;CSS in the global section&lt;/a&gt; and &lt;a href="http://docs.kynetx.com/docs/Use_resource"&gt;load external CSS files&lt;/a&gt;. However, both methods insert the CSS into the page every time the Ruleset is evaluated. I really did not want to load hundreds of lines of useless CSS into every page.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a class="big_button" href="http://ktest.heroku.com/a169x448"&gt;View Demo Online&lt;/a&gt; &lt;a class="big_button" href="https://gist.github.com/1315433"&gt;Download Source Code&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;My solution was to harvest the load external stylesheet code from the KRL runtime and wrap it in a &lt;a href="http://docs.kynetx.com/docs/Defaction"&gt;defaction&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript"&gt;loadStylesheet = defaction(cssURL) {&lt;br /&gt;  loadCode = &amp;lt;&amp;lt;&lt;br /&gt;    var head=document.getElementsByTagName('head')[0];&lt;br /&gt;    var new_style_sheet=document.createElement("link");&lt;br /&gt;    new_style_sheet.href="#{cssURL}";&lt;br /&gt;    new_style_sheet.rel="stylesheet";&lt;br /&gt;    new_style_sheet.type="text/css";&lt;br /&gt;    head.appendChild(new_style_sheet);&lt;br /&gt;  &amp;gt;&amp;gt;;&lt;br /&gt;  emit &amp;lt;&amp;lt; eval(loadCode);  &amp;gt;&amp;gt;;&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now I can load external stylesheets programatically:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript"&gt;rule inject_css {&lt;br /&gt;  select when click "#ignite"&lt;br /&gt;  {&lt;br /&gt;    loadStylesheet("http://assets.lobosllc.com/css/inception.css");&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a class="big_button" href="http://ktest.heroku.com/a169x448"&gt;View Demo Online&lt;/a&gt; &lt;a class="big_button" href="https://gist.github.com/1315433"&gt;Download Source Code&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1930213017396645687-2555855760959979376?l=edoism.orcutt.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edoism.orcutt.org/feeds/2555855760959979376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://edoism.orcutt.org/2011/10/css-inception-with-kynetx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/2555855760959979376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/2555855760959979376'/><link rel='alternate' type='text/html' href='http://edoism.orcutt.org/2011/10/css-inception-with-kynetx.html' title='CSS Inception with Kynetx'/><author><name>Ed Orcutt</name><uri>http://www.blogger.com/profile/01072069799127687951</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_tXU2PrpKxHU/SuDD5YwomTI/AAAAAAAAAII/hCrRNUZWOto/S220/edo_transjpg.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-Dsb6t-9Myoc/TqeYX4JIEjI/AAAAAAAAAUI/NfpeRgrFPgc/s72-c/CSS_Inception_300x250.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
