textarea {resize:none}
Tuesday, 16 October 2012
Stop or disable resizing textarea FireFox
FireFox has a feature which allows to resize multi-line textboxes (textareas). This is done by clicking and dragging at the bottom right corner of the textarea. It is a nice feature but in some cases we may have to restrict or stop the user from doing it. If so it can be achieved using below CSS.
Wednesday, 25 July 2012
Remove specific element from a javascript array
JavaScript Array has a splice() method which can be used to remove an element or set of elements starting from a given index.
First, find the index of the element you want to remove:
var array = [2, 5, 9]; var index = array.indexOf(2);Then remove it with splice:
array.splice(index,1);
How to break out of jQuery.each()?
JavaScript break statement doesn't work with jQuery.each(). But the same functionality can be achieved by adding a "return false" statement within jQuery.each() once the breaking condition is reached.
$(‘ul li’).each(function(index){
if ( $(this).hasClass(‘selected’) )
{
selected = index;
return false;
}
});
Html.Partial vs Html.RenderPartial
Html.Partial returns a string, Html.RenderPartial calls Write internally, and returns void.
The usage (using Razor syntax):
@Html.Partial("ViewName")
@{ Html.RenderPartial("ViewName"); }
The usage (using WebForms syntax):
<%: Html.Partial("ViewName") %>
<% Html.RenderPartial("ViewName"); %>
Will do exactly the same.
You can store the output of Html.Partial in a variable, or return it from a function. You cannot do this with Html.RenderPartial. The result will be written to the Response stream during the execution.
The same is true for Html.Action and Html.RenderAction.
Asp.Net MVC partial view controller action
While you can have an action that returns a partial view, you don't need an action to render a partial view. RenderPartial takes the partial view and renders it, using the given model and view data if supplied, into the current (parent) view.
Html.RenderPartial( "Partial");You might want an action that returns a partial view if you are using AJAX to load/reload part of a page. In that case, returning the full view is not desired since you only want to reload part of the page. In this case you can have the action just return the partial view that corresponds to that section of the page.
public ActionResult Action(...)
{
return PartialView( "Partial");
}
How slow is jQuery "slow"?
jQuery animation methods like fadeIn() allows you to specify whether you want to do the animation 'slow' or 'fast'.
In fact durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively. If any other string is supplied, or if the duration parameter is omitted, the default duration of 400 milliseconds is used.
How to detect IE7 with jQuery?
jQuery has a property called "$.browser.msie" which returns true when the browser is Internet Explorer. It can be combined with "$.browser.version" to decide what version of IE it is.
if ($.browser.msie && parseInt($.browser.version, 10) === 7) {
alert('IE7');
} else {
alert('Non IE7');
}
Subscribe to:
Posts (Atom)