Hi,
I have this javascript inside of a form. It serves to input data into the form if it was copied from already existing item (data is collected by another JS function and put into localStorage).
Problem is that I do not seem to be able to click on the link to add new rows to repeater section. Please see comments in the code.
NWF$(document).ready(function(){
var LocationField = NWF$('#' + ddLocationField);
var VisitReasonField = NWF$('#' + ddVisitReason);
var IntReqField = NWF$('#' + cbInternetReq);
var ParkReqField = NWF$('#' + cbParkingReq);
var SpecificsField = NWF$('#' + mltSpecifics);
if (localStorage.locVal && localStorage.vReasonVal && localStorage.iIntVal && localStorage.pParkVal && localStorage.sSpecsVal && localStorage.rRepeaterContent && localStorage.HowManyRows) {
var repeaterContentArr = JSON.parse(localStorage.getItem("rRepeaterContent"));
var HowManyRowsVal = parseInt(localStorage.HowManyRows);
LocationField.val(localStorage.locVal);
VisitReasonField.val(localStorage.vReasonVal);
if (localStorage.iIntVal=="true") {
IntReqField.click(); THIS WORKS (check box YES/NO)
}
if (localStorage.pParkVal=="true") {
ParkReqField.click(); THIS WORKS (check box YES/NO)
}
if (localStorage.sSpecsVal !="undefined") {
SpecificsField.val(localStorage.sSpecsVal);
}
var repeaterNewRowLink = NWF$('.visitors_repeater').find('a');
for (var i = 1;i < HowManyRowsVal;i++) {
repeaterNewRowLink.click(); THIS IS EXECUTED BUT THE ROWS ARE NOT ADDED (new row link on the repeater)
}
localStorage.removeItem("locVal");
localStorage.removeItem("vReasonVal");
localStorage.removeItem("iIntVal");
localStorage.removeItem("pParkVal");
localStorage.removeItem("sSpecsVal");
localStorage.removeItem("rRepeaterContent");
localStorage.removeItem("HowManyRows");
}
});
If I wait until the content of the page is visible and then run this manually in the console
var repeaterNewRowLink = NWF$('.visitors_repeater').find('a');
repeaterNewRowLink.click();
all works fine and repeater rows are added.
Is there any way how to click that link inside document ready function please?
Many thanx for reply
Jan