Skip to content

Instantly share code, notes, and snippets.

@ramhoj
Created February 29, 2012 16:31
Show Gist options
  • Select an option

  • Save ramhoj/1942266 to your computer and use it in GitHub Desktop.

Select an option

Save ramhoj/1942266 to your computer and use it in GitHub Desktop.
Date picker defaults
var occurrences = $(".occurrences");
if(occurrences.find(".error").length > 0) {
occurrences.find("a.add").hide();
} else {
occurrences.find(".fields:not(:has(input[type='checkbox'])):not(:first)").hide();
occurrences.find("a.add").click(function(e) {
var prevOccurrence = occurrences.find(".fields:not(:hidden):last");
var nextOccurrence = occurrences.find(".fields:hidden:first");
var inputs = "input[type='text'], select";
// Start of copy-over values spike
prevOccurrence.find(inputs).each(function(i, e) {
var source = $(e).val();
var destination = $(nextOccurrence.find(inputs).get(i));
destination.val(source);
});
// End of copy-over values spike
nextOccurrence.show();
e.preventDefault();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment