public static string Render()
{
var values = Enum.GetValues(typeof(Fixture));
string spool = values.Cast<object>().Aggregate("", (current, value) => current + value +
" ");
return spool.Trim();
}
Tuesday, November 5, 2013
Cast everything in a C# enum to a space separated string!
Monday, November 4, 2013
There does not seem to be a good way to decorate a textarea with readonly and still be able to "select all" on its contents in iOS.
overflow-y: scroll;
Saturday, November 2, 2013
sniff and set HTML element styles with jQuery
$(function () {
var loop = function () {
var style = $("#brain").attr('style');
if (style == "display: none;") {
$("#brain").attr('style', "display: block;");
} else {
$("#brain").attr('style', "display: none;");
}
};
var interval = setInterval(loop, 2000);
});
Styles.Render versus Scripts.Render
@Styles.Render("~/Content/css")
&
@Scripts.Render("~/bundles/modernizr")
...will both go fishing in BundleConfig.cs in the App_Start folder of an ASP.NET Web API with MVC Visual Studio 2013 project. Where they will find...
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
&
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
...respectively. It is important to note the difference in the HTML that Styles and Scripts spit up to the browser however. The stuff above gives us back...
<link href="/Content/site.css" rel="stylesheet"/>
&
<script src="/Scripts/modernizr-2.6.2.js"></script>
...respectively.
Friday, November 1, 2013
mytextarea.setSelectionRange(0, mytextarea.value.length);
It turns out there is a way to spin a timer to wait for a JavaScript promise to resolve, you just have to use a piece of the DOM as a middleman.
widget.kickOffPromiseToUpdateTextArea();
var loop = function(){
var textarea = widget.ourTextArea;
var characterCount = textarea.innerHTML.length;
if (characterCount != 0) {
clearInterval(interval);
alert('made it!');
goDoSomethingElseWithFeedBack(textarea.innerHTML);
} else {
alert('not yet!');
}
};
var interval = setInterval(loop, 6000);