I added the signature code to a form that I am also using pagination on. When the form loads the the signature space is small and unusable, however if i refresh the same instance of the form the signature space is correct and usable. I am sure it is something in the code I have, but am unsure as to where.
Any help would be greatly appreciated. ![]()
$(document).ready(function () {
$('.sections, .Submit').hide();
$('.section1').show();
$('.navitem').on('touchstart click', function () {
$('.sections').hide();
$('.navbar').find('.navitem').removeClass('selected');
if ($(this).hasClass('deposit')) {
$('.section1').show();
$('.navbar').find('.deposit').addClass('selected');
}
else if ($(this).hasClass('personal')) {
$('.section2').show();
$('.navbar').find('.personal').addClass('selected');
}
else if ($(this).hasClass('employment')) {
$('.section3').show();
$('.navbar').find('.employment').addClass('selected');
}
else if ($(this).hasClass('retirement')) {
$('.section4').show();
$('.navbar').find('.retirement').addClass('selected');
}
else if ($(this).hasClass ('fica')) {
$('.section5').show();
$('.navbar').find('.fica').addClass('selected');
}
else if ($(this).hasClass ('sign')) {
$('.section6').show();
$('.navbar').find('.sign').addClass('selected');
}
})
$('.navitem.info').trigger('click');
});
function htmlEncode(value) {
return $('<div/>').text(value).html();
}
function htmlDecode(value) {
return $('<div/>').html(value).text();
}
$.getScript('http://trtc843/forms/js/jSignature.min.js', function () {
$('.signature').jSignature();
});
/**When the page loads, check if the sig data (hidden) field has a value.
If it has a value, decode it and put it in the image, and remove the
signature pad and its buttons.**/
$(document).ready(function(){
$('.sigCollection').each(function () {
var sigvalue = $(this).find('.sigdata textarea').text();
var sigrovalue = $(this).find('.sigdata .ro').text();
if (sigvalue != '' || sigrovalue != '') {
var decoded = htmlDecode(sigvalue == '' ? sigrovalue : sigvalue);
var $img = $('<img class=imported></img>');
$img.attr("src", decoded).appendTo($(this).find('.sigimage'));
$(this).find('.sigGroup').remove(); //class added to the signature button and image custom HTML fields.
$(this).find('.sigwarning').hide();
}
});
$('.donebutton').click(function () {
var section = $(this).closest('.sigCollection');
var sigdata = section.find('.signature').jSignature('getData');
section.find('.sigdata textarea').val(htmlEncode(sigdata));
var $img = $('<img class=imported></img>');
$img.attr("src", section.find('.signature').jSignature('getData')).appendTo(section.find('.sigimage'));
section.find('.sigGroup').remove(); //class added to the signature button and image custom HTML fields.
section.find('.sigwarning').hide();
$('.Submit').show();
});
$('.clearbutton').click(function () {
var section = $(this).closest('.sigCollection');
section.find('.signature').jSignature('clear');
});
});