Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically loaded css doesn't set width property
    primarykey
    data
    text
    <p>I'm trying to dynamically load css file using javascript, and for a moment i'we think it works. But in the next moment i realise, that elements on page didn't get "width" from css file. Everything else work's ok. I check css in chrome browser from same page and it is fully loaded. What have i done wrong?</p> <p>Script for load css/js files(i found it on web):</p> <pre><code>function loadjscssfile(filename, filetype){ if (filetype=="js"){ //if filename is a external JavaScript file var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename) } else if (filetype=="css"){ //if filename is an external CSS file var fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", filename) } if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref) } } </code></pre> <p>And the other jquery code:</p> <pre><code>$(this).addClass('iG_Main'); loadjscssfile(data.theme_url,'css'); createGrid($($(this).selector+'.iG_Main')); function createGrid( selector ){ var cellWidth, columnValue; var blank = '&amp;nbsp;'; selector.append('&lt;div class="iG_Header"&gt;&lt;/div&gt;'); selector.append('&lt;div class="iG_Container"&gt;&lt;/div&gt;'); selector.append('&lt;div class="iG_Footer"&gt;This is footer!&lt;/div&gt;'); selector_header = selector.children('.iG_Header'); selector_container = selector.children('.iG_Container'); selector_footer = selector.children('.iG_Footer'); selector_header.append('&lt;div class="iG_Cell iG_CheckBox inHead"&gt;&lt;div id="iG_CheckBox"&gt;'+ blank +'&lt;/div&gt;&lt;/div&gt;'); if(undefinedVal(data.width)) data.width = 1000; if(undefinedVal(data.height)) data.height = 400; for(var i in data.headerData) selector_header.append('&lt;div id="'+ data.headerData[i].name +'" class="iG_Cell inHead"&gt;&lt;div&gt;'+ data.headerData[i].label +'&lt;/div&gt;&lt;/div&gt;'); if(data.options){ selector_header.append('&lt;div class="iG_Cell Options inHead"&gt;&lt;div&gt;'+ blank +'&lt;/div&gt;&lt;/div&gt;'); // cellWidth = (data.width-40-15)/(data.headerData.length); cellWidth = (data.width-$('.iG_Cell.inHead.Options').width()-selector_header.children('.iG_CheckBox').width())/(data.headerData.length); }else cellWidth = (data.width-15-selector_header.children('.iG_CheckBox').width())/(data.headerData.length); //15 - in sake of scrollbar //}else cellWidth = (data.width-15-40)/(data.headerData.length); //15 - in sake of scrollbar for(var i in data.contentData){ selector_container.append('&lt;div class="iG_Content"&gt;&lt;/div&gt;'); selector_container.children('.iG_Content:last-child').append('&lt;div class="iG_Cell iG_CheckBox inContent"&gt;&lt;div id="iG_CheckBox"&gt;'+ blank +'&lt;/div&gt;&lt;/div&gt;'); for(var j in data.headerData){ columnValue = (undefinedVal(data.contentData[i][data.headerData[j].name])) ? blank : data.contentData[i][data.headerData[j].name]; selector_container.children('.iG_Content:last-child').append('&lt;div class="iG_Cell"&gt;&lt;div&gt;'+ columnValue +'&lt;/div&gt;&lt;/div&gt;'); } selector.css({'width':data.width, 'height':data.height}); selector_header.children('.iG_Cell').not('.Options').not('.iG_CheckBox').css('width',cellWidth); selector_container.children('.iG_Content').children('.iG_Cell').not('.iG_CheckBox').css('width',cellWidth); selector_container.css('height', data.height-selector_header.height()-selector_footer.height()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload