This code was spent my whole day to fix it and there seem no way I can find, but by posting a question here.
FIDDLE
$('.git_this_similar').on('change', function(){
if($(this).is(":checked")) {
$(this).closest('.gscpc_right_col_inner')
.find('#git_wpost_fname, #git_wpost_imgtitle,
#git_wpost_shortdesc, #git_wpost_tags')
.attr("disabled", true);
$(this).closest('.gscpc_right_col_inner')
.find('.git_wpost_titleclass').on('keyup', function(){
$(this).closest('.gscpc_right_col_inner')
.find('#git_wpost_imgtitle, #git_wpost_shortdesc')
.val($(this).val());
var fileextension = $(this).closest('.gscpc_right_col_inner')
.find('#git_wpost_fname').val();
var lastFour = '.' + fileextension.split(".").pop();
var gitfilename = $(this).val().toLowerCase().replace(/[\W]+/g, "_") + lastFour;
$(this).closest('.gscpc_right_col_inner')
.find('#git_wpost_fname').val(gitfilename);
var git_tags = $(this).val().split(' ').join(', ');
$(this).closest('.gscpc_right_col_inner')
.find('#git_wpost_tags').val(git_tags);
});
} else {
// turn off 'disabled' attribute
$(this).closest('.gscpc_right_col_inner')
.find('#git_wpost_fname, #git_wpost_imgtitle,
#git_wpost_shortdesc, #git_wpost_tags')
.attr("disabled", false);
$(this).closest('.gscpc_right_col_inner')
.find('.git_wpost_titleclass')
.on('keyup', function(){});
}
});
What I actually want to do is:
After the checkbox is clicked
> IF ( the checkbox is checked)
> {
> Use "Post Title" field value for all input fields!
> }
> ELSE
> {
> Don't use "Post Title" field value for other input fields!
> }
But what I get here is the other fields value keep following the "Post Title" value when it is changed while the checkbox is not checked.
What should I do to kill the keyup
effect that happened when the checkbox was checked?