putting datepicker() on dynamically created elements – JQuery/JQueryUI

here is the trick: $(‘body’).on(‘focus’,”.datepicker_recurring_start”, function(){ $(this).datepicker(); });​ DEMO The $(‘…selector..’).on(‘..event..’, ‘…another-selector…’, …callback…); syntax means: Add a listener to …selector.. (the body in our example) for the event ..event.. (‘focus’ in our example). For all the descendants of the matching nodes that matches the selector …another-selector… (.datepicker_recurring_start in our example) , apply the event handler … Read more

How can I custom-format the Autocomplete plug-in results?

Yes, you can if you monkey-patch autocomplete. In the autocomplete widget included in v1.8rc3 of jQuery UI, the popup of suggestions is created in the _renderMenu function of the autocomplete widget. This function is defined like this: _renderMenu: function( ul, items ) { var self = this; $.each( items, function( index, item ) { self._renderItem( … Read more

jQuery UI datepicker change event not caught by KnockoutJS

I think that for the jQuery UI datepicker it is preferable to use a custom binding that will read/write with Date objects using the APIs provided by the datepicker. The binding might look like (from my answer here): ko.bindingHandlers.datepicker = { init: function(element, valueAccessor, allBindingsAccessor) { //initialize datepicker with some optional options var options = … Read more

MVC Force jQuery validation on group of elements

You can validate individual controls using Validator.element(element) – see documentation here, so you could use the following approach (you haven’t posted the views html so can’t write the actual code for you) In the Next button click event Select all the the controls within the associated div – e.g. var controls = $(this).closest(‘div’).find(‘input, textarea, select’); … Read more

jQuery UI DatePicker to show month year only

Here’s a hack (updated with entire .html file): <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”> <head> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js”></script> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js”></script> <link rel=”stylesheet” type=”text/css” media=”screen” href=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css”> <script type=”text/javascript”> $(function() { $(‘.date-picker’).datepicker( { changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: ‘MM yy’, onClose: function(dateText, inst) { $(this).datepicker(‘setDate’, new Date(inst.selectedYear, inst.selectedMonth, 1)); … Read more