Tuesday, 15 May 2012

Quickest way to add CSS and JavaScript to Sitecore -



Quickest way to add CSS and JavaScript to Sitecore -

i have single page within sitecore, containing html table. i've added css , javascript page, through sitecore html editor allow datatables.net format table.

this work well, except when regular user goes update table using rich text editor, css , javascript removed.

i can add together css generic css files, javascript contains initialization logic, needs on page itself.

what's easy way add together references css , javascript files?

there setting in web.config true default.

<setting name="htmleditor.removescripts" value="true"/>

setting false prevent rich text editor stripping out script blocks. aware impact every single rich text field in site, , set in there safety precaution. can take @ this blog post more info.

there other code solutions, adding multiline text field scripts not strip out require modifying layout files if comfortable editing css file suggest same javascript file, add together unique id/selector table (in rte) , initialize there. e.g.

$(document).ready(function() { $('#mycustomdatatable').datatable( { "paging": false, "ordering": false, "info": false } ); } );

as long selector targets table uniquely , js files loaded on page run , format table.

sitecore

No comments:

Post a Comment