Skip to content

Commit

Permalink
Use .prop() instead of .attr() with jQuery
Browse files Browse the repository at this point in the history
jQuery 1.6 introduced the .prop() method which replaces .attr() for
numerous cases. Using .prop() solves a number of issues experienced by
browsers when rendering with application/xhtml+xml MIME type.

Full information on why this change is necessary and the details of
.prop() and .attr() can be found at:
http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/
  • Loading branch information
davidhicks committed Jul 19, 2011
1 parent e8602a3 commit 07fdb1f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions javascript/common.js
Expand Up @@ -105,11 +105,11 @@ $(document).ready( function() {
var checkedCount = $(this).closest('form').find(':checkbox[name="' + fieldName + '[]"]:checked').length;
var totalCount = $(this).closest('form').find(':checkbox[name="' + fieldName + '[]"]').length;
var allSelected = checkedCount == totalCount;
$(this).closest('form').find(':checkbox[name=' + fieldName + '_all]').attr('checked', allSelected);
$(this).closest('form').find(':checkbox[name=' + fieldName + '_all]').prop('checked', allSelected);
});
$(':checkbox.check_all').click(function() {
var baseFieldName = $(this).attr('name').replace(/_all$/, '');
$(this).closest('form').find(':checkbox[name="' + baseFieldName + '[]"]').attr('checked', $(this).is(':checked'));
$(this).closest('form').find(':checkbox[name="' + baseFieldName + '[]"]').prop('checked', $(this).is(':checked'));
});
}

Expand Down Expand Up @@ -207,30 +207,30 @@ $(document).ready( function() {

$('input[type=checkbox]#use_date_filters').live('click', function() {
if (!$(this).is(':checked')) {
$('div.filter-box select[name=start_year]').attr('disabled', 'disabled');
$('div.filter-box select[name=start_month]').attr('disabled', 'disabled');
$('div.filter-box select[name=start_day]').attr('disabled', 'disabled');
$('div.filter-box select[name=end_year]').attr('disabled', 'disabled');
$('div.filter-box select[name=end_month]').attr('disabled', 'disabled');
$('div.filter-box select[name=end_day]').attr('disabled', 'disabled');
$('div.filter-box select[name=start_year]').prop('disabled', true);
$('div.filter-box select[name=start_month]').prop('disabled', true);
$('div.filter-box select[name=start_day]').prop('disabled', true);
$('div.filter-box select[name=end_year]').prop('disabled', true);
$('div.filter-box select[name=end_month]').prop('disabled', true);
$('div.filter-box select[name=end_day]').prop('disabled', true);
} else {
$('div.filter-box select[name=start_year]').removeAttr('disabled');
$('div.filter-box select[name=start_month]').removeAttr('disabled');
$('div.filter-box select[name=start_day]').removeAttr('disabled');
$('div.filter-box select[name=end_year]').removeAttr('disabled');
$('div.filter-box select[name=end_month]').removeAttr('disabled');
$('div.filter-box select[name=end_day]').removeAttr('disabled');
$('div.filter-box select[name=start_year]').prop('disabled', false);
$('div.filter-box select[name=start_month]').prop('disabled', false);
$('div.filter-box select[name=start_day]').prop('disabled', false);
$('div.filter-box select[name=end_year]').prop('disabled', false);
$('div.filter-box select[name=end_month]').prop('disabled', false);
$('div.filter-box select[name=end_day]').prop('disabled', false);
}
});

/* For Period.php bundled with the core MantisGraph plugin */
$('#dates > input[type=image].datetime').hide();
$('#period_menu > select#interval').change(function() {
if ($(this).val() == 10) {
$('#dates > input[type=text].datetime').removeAttr('disabled');
$('#dates > input[type=text].datetime').prop('disabled', false);
$('#dates > input[type=image].datetime').show();
} else {
$('#dates > input[type=text].datetime').attr('disabled', 'disabled');
$('#dates > input[type=text].datetime').prop('disabled', true);
$('#dates > input[type=image].datetime').hide();
}
});
Expand Down

0 comments on commit 07fdb1f

Please sign in to comment.