I have the following code:
$('#modal .update-title')
.change(function () {
var title = $('option:selected', this).prop('title');
$(this).prop('title', title);
// For the question screen, after the initial set up
// changes move the title to the title input field.
if ($(this).data('propagate-title') === 'yes') {
var m = this.id.match(/^modal_TempRowKey_(\d+)$/);
if (m) {
$("#modal_Title_" + m[1]).val(title);
}
}
});
When I run jslint it gives me the following error:
Combine this with the previous 'var' statement.
var m = this.id.match(/^modal_TempRowKey_(\d+)$/);
is jslint wrong or am I wrong?
using the if condition does not create a new scope. so the variable m only exist if the condition is true. So here is what you can do