Contents tagged with jquery

  • Working with Kendo UI Templates

    I’m watching the Introduction to Kendo UI course by Keith Burnell on Pluralsight and decided to play around a little bit with templates, which are a pretty powerful feature.  If you’re a server-side web developers, templates should seem pretty familiar to you.  Any ASP or ASP.NET page can be thought of like a template, in which you mix markup and dynamic data expressions.  In this case, the templates are defined in their own script blocks.  There are demos and documentation available; in my case I opted to write something up based on what’s in the Pluralsight course in a JSFiddle. Templates are most valuable when you’re binding some data to them.  The data can be … more

  • Passing Default Parameter Objects in JavaScript

    You can use the jQuery extend() function to elegantly configure your functions to accept a single parameter object, while providing default behavior for any options that are not set.  For instance, imagine you have a simple function that simply says “Hello, World”.  You could code it like this: Now, if you want to start passing in parameters, you can easily do so by parameterizing the method, but every time you do, you break any code that was expecting the original parameterless version.  This can quickly grow out of hand within a few revisions of the function’s signature.  A simple way to avoid this issue and allow for your function to version forward effectively is to … more

  • Wiring Up TimeAgo and ASPNET MVC

    Imagine you want to display something on a page so that instead of raw dates, the user is shown something more relative to the current time.  You’ve probably seen this in some of the applications you use.  “Last Updated: A moment ago” or “about an hour ago”.  There are a variety of ways you can implement this, and it’s been done in many different languages.  In my case, which is an ASP.NET MVC C# application, I considered doing it on the server and simply passing the result as a string to the view for display.  However, in searching for the best way to do this, I stumbled upon the Timeago plugin for jQuery. One of the key benefits of this plugin is that, unlike … more

  • Modifying and Disabling Hyperlinks using jQuery

    I have a simple menu in an ASP.NET MVC application allows a user to take one of several actions after first selecting a resource to work with from a drop down list / select box or textbox.  In the case where the user hasn’t yet selected anything (or entered any text), I want the links to be disabled, as I’d rather let the user know the issue on the current dashboard page than have them go to a page without a required parameter and then hit them with an error message about the missing parameter.  Instead, I’d like to, in the case of the empty textbox, give the textbox focus and flash some color there so the user (usually me) knows they need to enter something there before … more