I have a
TextBox (id=txtFilterValue),
Add button (id=btnAdd) and
Table (id=queryTable)
once user enter the value in text box, they may press the enter key. So when they press the enter key, it should call the Add Button which is already defined in jquery.
This is What I tried
Jquery Code
//Preventing ENTER Key
$('#form1').on('keyup keypress', function (e) {
var keyCode = e.keyCode || e.which;
if (keyCode === 13) {
//$('input[name = btnAdd]').click();
$("#btnAdd").trigger('click');
e.preventDefault();
return false;
}
});
The above code to prevent the enter key and it will call the Add Button.
As I thought it's working. But it's calling two times and the values are adding 2 times. It shouldn't add two times.
when I click the Add button directly, it's entering the record only one to my table.
This is my button Add code
//Filter Query Add to TABLE and TEXTBOX
$("#btnAdd").click(function () {
var selectedField = $("#FilterField option:selected").text();
var operator = $("#ddlOperator :selected").val();
var filterValue = $("#txtFilterValue").val();
var query;
var textFilterRecord = $("#txtFilterRecord").val();
//values seperated by COMMA
var arrayTxtConditionValue = filterValue.split(',');
if (operator == 'equalTo') {
if ($("#txtFilterRecord").val().length == 0) {
//put the single quotation( ' ) in between values
var filterCommaValue = '';
for (var i = 0; i < arrayTxtConditionValue.length; i++) {
if (i == 0) {
filterCommaValue = filterCommaValue + "'" + arrayTxtConditionValue[i] + "'";
}
else {
filterCommaValue = filterCommaValue + ",'" + arrayTxtConditionValue[i] + "'";
}
}
query = selectedField + ' IN(' + filterCommaValue + ') ';
$("#txtFilterRecord").val($("#txtFilterRecord").val() + query);
$("#queryTable > tbody:last-child").append('<tr><td class="FieldNameID">' + selectedField + '</td><td class="OperatorID"> IN(' + filterCommaValue + ')</td></tr>');
}
else {
var filterCommaValue = '';
for (var i = 0; i < arrayTxtConditionValue.length; i++) {
if (i == 0) {
filterCommaValue = filterCommaValue + "'" + arrayTxtConditionValue[i] + "'";
}
else {
filterCommaValue = filterCommaValue + ",'" + arrayTxtConditionValue[i] + "'";
}
}
var radioButton = $('input[name=group]:checked').val();
query = radioButton + ' ' + selectedField + ' IN(' + filterCommaValue + ') ';
$("#txtFilterRecord").val($("#txtFilterRecord").val() + query);
$('#queryTable > tbody:last-child').append('<tr><td class="FieldNameID">' + radioButton + ' ' + selectedField + '</td><td class="OperatorID"> IN(' + filterCommaValue + ')</td></tr>');
}
}
});
$('#form1').on('keyup keypress', function (e) {
// ...
Here you are listening for two events with the same callback. That means whenever one of them occur the callback will be called. Since they're both related to the key events (both are pretty much the same), the callback will be called twice.
So just remove one of them like this:
$('#form1').on('keypress', function (e) {
// ...
Related
I apologize up front for the possible lack of clarity for this question, but I'm new to Angular.js and my knowledge of it is still slightly hazy. I have done the Angular.js tutorial and googled for answers, but I haven't found any.
I have multiple select/option html elements, not inside a form element, and I'm populating them using AJAX. Each form field is populated by values from a different SharePoint list. I'm wondering if there is a way to implement this using Angular.js?
I would like to consider building this using Angular because I like some of it features such as data-binding, routing, and organizing code by components. But I can't quite grasp how I could implement it in this situation while coding using the DRY principle.
Currently, I have a single AJAX.js file and I have a Javascript file that contains an array of the different endpoints I need to connect to along with specific query parameters. When my page loads, I loop through the arrays and for each element, I call the GET method and pass it the end-point details.
The code then goes on to find the corresponding select element on the page and appends the option element returned by the ajax call.
I'm new to Angular, but from what I understand, I could create a custom component for each select element. I would place the component on the page and all the select and options that are associated with that component would appear there. The examples I've seen demonstrated, associate the ajax call with the code for the component. I'm thinking that I could use a service and have each component dependent on that service and the component would pass it's specific query details to the service's ajax call.
My current code - Program flow: main -> data retrieval -> object creation | main -> form build.
Called from index.html - creates the multiple query strings that are passed to ajax calls - ajax calls are once for each query string - the very last function in the file is a call to another function to build the form elements.
var snbApp = window.snbApp || {};
snbApp.main = (function () {
var main = {};
main.loadCount = 0;
main.init = function () {
function buildSelectOptions(){
//***
//Build select options from multiple SharePoint lists
//***
var listsArray = snbApp.splistarray.getArrayOfListsForObjects();
for(var i = 0; i < listsArray.length; i++){
var listItem = listsArray[i];
var qryStrng = listItem.list +
"?$select=" + listItem.codeDigits + "," + listItem.codeDescription + "," + listItem.ItemStatus + "&$orderby=" + listItem.codeDescription + "&$filter="+listItem.ItemStatus+" eq true" + "&$inlinecount=allpages"
var listDetails = {
listName: listItem.list,
listObj: listItem,
url: "http://myEnv/_vti_bin/listdata.svc/" + listItem.list +
"?$select=" + listItem.codeDigits + "," + listItem.codeDescription + "," + listItem.ItemStatus + "&$orderby=" + listItem.codeDescription + "&$filter="+listItem.ItemStatus+" eq true" + "&$inlinecount=allpages"
};
var clientContext = new SP.ClientContext.get_current();
clientContext.executeQueryAsync(snbApp.dataretriever.letsBuild(listDetails), _onQueryFailed);
}
//***
//Build select option from other API endpoint
//***
var listDetails = {
listName:"SNB_SecondaryActivityCodes",
url: "http://myEnv/requests/odata/v1/Sites?$filter=(IsMajor eq true or IsMinor eq true) and IsActive eq true and IsPending eq false and CodePc ne null and IsSpecialPurpose eq false&$orderby=CodePc"
};
snbApp.dataretriever.letsBuild(listDetails);
}
buildSelectOptions();
//***
//Add delay to populate fields to ensure all data retrieved from AJAX calls
//***
var myObj = setTimeout(delayFieldPopulate,5000);
function delayFieldPopulate(){
var optObj = snbApp.optionsobj.getAllOptions();
var osType = $("input[name=os_platform]:checked").val();
snbApp.formmanager.buildForm(osType, optObj);
}
};
function _onQueryFailed(sender, args) {
alert('Request failed.\nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
}
return main
})();
AJAX calls here - called from main/previous file:
var snbApp = window.snbApp || {};
snbApp.dataretriever = (function () {
var listsArray = snbApp.splistarray.getArrayOfListsForObjects();
function getListData(listItem) {
var eventType = event.type;
var baseURL = listItem.url;
$.ajax({
url: baseURL,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
}
})
.done(function(results){
snbApp.objectbuilderutility.buildObjectFields(results, listItem);
})
.fail(function(xhr, status, errorThrown){
//console.log("Error:" + errorThrown + ": " + myListName);
});
}
function _onQueryFailed(sender, args) {
alert('Request failed.\nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
}
return{
letsBuild:function(item) {
getListData(item);
}
};
})();
Builds a item name object - called from recursive AJAX calls / previous file
var snbApp = window.snbApp || {};
snbApp.objectbuilderutility = (function () {
function formatItemCode(itemCode, eventType){
if(eventType !== 'change'){ //for load event
var pattern = /^CE/;
var result = pattern.test(itemCode);
if(result){
return itemCode.slice(2);
}else{
return itemCode.slice(0,3);
}
}else{ //for change event
var pattern = /^CE/;
var result = pattern.test(itemCode);
if(result){
return itemCode.slice(2);
}else{
return itemCode.slice(3);
}
}
}
return{
buildObjectFields: function(returnedObj, listItem){ //results:returnedObj, prevItem:listItem
//***
//For SharePoint list data
//***
if (listItem.listName !== "SNB_SecondaryActivityCodes") {
var theList = listItem.listName;
var firstQueryParam = listItem.listObj.codeDigits;
var secondQueryParam = listItem.listObj.codeDescription;
var returnedItems = returnedObj.d.results;
var bigStringOptions = "";
//regex to search for SecondaryFunctionCodes in list names
var pattern = /SecondaryFunctionCodes/;
var isSecFunction = pattern.test(theList);
if(isSecFunction){
bigStringOptions = "<option value='0' selected>Not Applicable</option>";
}else{
bigStringOptions = "<option value='0' disabled selected>Select Option</option>";
}
$.each(returnedItems, function (index, item) {
var first = "";
var second = "";
for (var key in item) {
if (item.hasOwnProperty(key)) {
if (key != "__metadata") {
if (key == firstQueryParam) {
first = item[key];
}
if (key == secondQueryParam) {
second = item[key];
}
}
}
}
bigStringOptions += "<option value=" + first + " data-code=" + first + ">" + second + "</option>";
});
var str = theList.toLowerCase();
snbApp.optionsobj.updateFunctionOrActivity(theList.toLowerCase(), bigStringOptions);
//***
//For other API
//***
} else {
var theList = listItem.listName;
var bigStringOptions = "<option value='0' disabled selected>Select Option</option>";
var returnedItems = returnedObj.value;
for(var i = 0; i < returnedItems.length; i++){
var item = returnedItems[i];
//***
//change event type means the user selected a field
//***
if(listItem.eventType === "change"){
var siteCodeChange = item.SiteCodePc;
if (typeof siteCodeChange === "string" & siteCodeChange != "null") {
siteCodeChange = siteCodeChange < 6 ? siteCodeChange : siteCodeChange.slice(3);
}
bigStringOptions += "<option value='" + item.Id + "' data-code='" + siteCodeChange + "' data-isDivSite='" + item.IsDivisionSite + "' data-isDistSite='" + item.IsDistrictSite + "' data-divID='" + item.DivisionSiteId + "' data-distID='" + item.DistrictSiteId + "'>(" + siteCodeChange + ") " + item.Name + "</option>";
snbApp.formmanager.buildSelectSiteLocations(bigStringOptions);
//***
//load event which means this happens when the page is loaded
//***
}else{
var siteCodeLoad = item.SiteCodePc;
if (typeof siteCodeLoad === "string" & siteCodeLoad != "null") {
var siteCodeLoad = siteCodeLoad.length < 4 ? siteCodeLoad : siteCodeLoad.slice(0, 3);
}
bigStringOptions += "<option value='" + item.Id + "' data-code='" + siteCodeLoad + "' data-isDivSite='" + item.IsDivisionSite + "' data-isDistSite='" + item.IsDistrictSite + "' data-divID='" + item.DivisionSiteId + "' data-distID='" + item.DistrictSiteId + "'>(" + siteCodeLoad + ") " + item.Name + "</option>";
snbApp.optionsobj.updateFunctionOrActivity(theList.toLowerCase(), bigStringOptions);
}
}
}
}
};
})();
Form management - called from previous file, gets all select elements on page and appends items from the object in previous file to each select element.
var snbApp = window.snbApp || {};
//Direct interface to the form on the page
snbApp.formmanager = (function(){
var form = {};
form.content_holder = document.getElementById("content_holder");
form.sec_act_codes = document.getElementById("snb_secondary_activity_codes");
form.prim_func_codes = document.getElementById("snb_primary_function_codes");
form.sec_func_codes = document.getElementById("snb_secondary_function_codes");
form.sec_func_nums = document.getElementById("snb_secondary_function_numbers");
form.host_options = document.getElementById("snb_host_options");
form.site_locs_div = document.getElementById("site_locations_div");
form.site_locs = document.getElementById("snb_site_locations");
form.dc_or_off_prem_div = document.getElementById("dc_or_off_premise_div");
form.dc_off_prem_codes = document.getElementById("snb_dc_offpremise_codes");
var snb_secondary_activity_codes = "";
var snb_primary_function_codes = "";
var snb_secondary_function_codes = "";
var snb_secondary_function_numbers = "";
var snb_host_options = "";
var snb_site_locations = "";
var snb_dc_op = "";
//builds the server location hosting options selection
function buildLocationTypeSelector() {
var locationOptionsString = "<option value='0' disabled selected>Select Option</option>";
for (var i = 0; i < locationOptions.length; i++) {
var location = locationOptions[i];
locationOptionsString += "<option value=" + location.hostLocale + " data-code=" + location.code + ">" + location.hostLocale + "</option>";
}
$("#snb_host_options").append(locationOptionsString);
}
function buildSiteLocations(bigString){
if(bigString === undefined){
var siteLocs = document.getElementById("snb_site_locations");
var newOption = document.createElement("option");
newOption.setAttribute("value", 0);
newOption.setAttribute("disabled","disabled");
newOption.setAttribute("checked","checked");
var newText = document.createTextNode("Select Option");
newOption.appendChild(newText);
siteLocs.appendChild(newOption);
} else{
var siteLocs = document.getElementById("snb_site_locations");
siteLocs.innerHTML = bigString;
}
}
return {
form:form,
buildSelectSiteLocations: function(bigString){
buildSiteLocations(bigString);
},
buildForm: function (osType, optObj) {
buildLocationTypeSelector();
buildSecondaryFunctionNumberSelector();
buildSiteLocations();
if(osType === 'windows'){
$("#snb_secondary_activity_codes").append(optObj.windows.secondary_activity);
$("#snb_primary_function_codes").append(optObj.windows.primary_function);
$("#snb_secondary_function_codes").append(optObj.windows.secondary_function);
$("#snb_site_locations").append(optObj.windows.site_location);
$("#snb_dc_offpremise_codes").append(optObj.windows.dc_offpremise);
}else{
$("#snb_secondary_activity_codes").append(optObj.unix.secondary_activity);
$("#snb_primary_function_codes").append(optObj.unix.primary_function);
$("#snb_secondary_function_codes").append(optObj.unix.secondary_function);
$("#snb_site_locations").append(optObj.unix.site_location);
$("#snb_dc_offpremise_codes").append(optObj.unix.dc_offpremise);
}
}
};
})();
Thanks in advance.
I have a requirement to call 4 java script function from codebehind page of asp.net page it works fine for 3 javascript function but if i add 4th which is a validation function. The validation function works but not the other 3.
This works!
btnSubmit.OnClientClick = "return Getprodsize('" + hdnprdsize.ClientID + "');return formatSpecifications('" + hdnSpecifications.ClientID + "');return Getselectedvalue('" + hdndrop.ClientID + "')";
This doesnt work...
btnSubmit.OnClientClick = "return Validate();Getprodsize('" + hdnprdsize.ClientID + "');return formatSpecifications('" + hdnSpecifications.ClientID + "');return Getselectedvalue('" + hdndrop.ClientID + "')";
function Validate() {
var existing = $("#ctl00_contentMain_lblProductleft").text();
if ($('#ctl00_contentMain_txtProductName').val() == '') {
$('#ctl00_contentMain_txtProductName').focus().css("border-color", "red");
return false;
}
if ($('#ctl00_contentMain_Txtbrandname').val() == '') {
$('#ctl00_contentMain_Txtbrandname').focus().css("border-color", "red");
return false;
}
if ($('#ctl00_contentMain_Txtstock').val() == '') {
$('#ctl00_contentMain_Txtstock').focus().css("border-color", "red");
return false;
}
if ($('#ctl00_contentMain_Txtprice').val() == '') {
$('#ctl00_contentMain_Txtprice').focus().css("border-color", "red");
return false;
}
if ($('#ctl00_contentMain_txtShortDescription').val() == '') {
$('#ctl00_contentMain_txtShortDescription').focus().css("border-color", "red");
return false;
}
if ($('#ctl00_contentMain_txtLongDescription').val() == '') {
$('#ctl00_contentMain_txtLongDescription').focus().css("border-color", "red");
return false;
}
if ($('#ctl00_contentMain_ddlbcatgory option:selected').val() == 0) {
alert("Please Select Catagory");
return false;
}
if ($('#ctl00_contentMain_txtdeleverycharge').val() == 0) {
$('#ctl00_contentMain_txtdeleverycharge').focus().css("border-color", "red");
return false;
}
var txval = $('input[name=optradio]:checked').val();
$('#<%=hdnTax.ClientID%>').val(txval);
return true;
}
You can't have multiple return statements in the onClientClick attribute. The first one will return, and the rest will not be executed. You should call the other functions without using return, and then return the value from the Validate() function.
btnSubmit.OnClientClick = "Getprodsize('" + hdnprdsize.ClientID + "'); formatSpecifications('" + hdnSpecifications.ClientID + "'); Getselectedvalue('" + hdndrop.ClientID + "'); return Validate();";
If you want to check the validation first, and not call the other functions if it fails, you use if
btnSubmit.OnClientClick = "if(Validate()) {Getprodsize('" + hdnprdsize.ClientID + "'); formatSpecifications('" + hdnSpecifications.ClientID + "'); Getselectedvalue('" + hdndrop.ClientID + "'); return true;} else return false";
It would be easier if you moved all this logic out to a new function, and just called that function in OnClientClick.
function validateAndFormat(sizeID, specID, dropID) {
if(Validate()) {
Getprodsize(sizeID);
formatSpecifications(specID);
Getselectedvalue(dropID);
return true;
} else {
return false
}
}
btnSubmit.OnClientClick = "validateAndFormat('" + hdnprdsize.ClientID + "', '" + hdnSpecifications.ClientID + "' + "', '" + hdndrop.ClientID + "');"
I have an Onchange Event Defined on a Textbox as below
$('input[ComponentAttribute]').on("change",function () {
dataTxt = "";
var thisID = $(this).attr('id');
var temp = $('#' + thisID).val();
if (!(temp.trim()=='')) {
// alert($(this).attr('ComponentAttributeID') + " - " + temp);
placeholder[$(this).attr('ComponentAttributeID')] = temp;
for (var key in placeholder) {
if (key === 'length' || !placeholder.hasOwnProperty(key)) continue;
var value = placeholder[key];
dataTxt += key + ":" + value + ";";
}
$('[DataAttributeValue]').text(dataTxt);
}
});
Now, the event fires when user enters value by keyboard. But when user selects a value from Autocomplete as shown, the Event don't fire. What am I missing here?
bus reservation
The following code generate multilpe <li> and when the user click seats, the selected seats css will change. but i want to restrict the multiple selection. the user has to be allow to select only one seat, if he select second <li> (seat) , then the first one has to go unselect
DEMO : http://demo.techbrij.com/780/seat-reservation-jquery-demo.php
CODE : http://techbrij.com/seat-reservation-with-jquery
$(function () {
var settings = {
rows: 6,
cols: 6,
rowCssPrefix: 'row-',
colCssPrefix: 'col-',
seatWidth: 30,
seatHeight: 30,
seatCss: 'seat',
selectedSeatCss: 'selectedSeat',
selectingSeatCss: 'selectingSeat'
};
var init = function (reservedSeat) {
var str = [], seatNo, className;
for (i = 0; i < settings.rows; i++) {
for (j = 0; j < settings.cols; j++) {
seatNo = (i + j * settings.rows + 1); // Seat No eg : seatNo = 0+0*0+1 (1)
className = settings.seatCss + ' ' + settings.rowCssPrefix + i.toString() + ' ' + settings.colCssPrefix + j.toString(); // Class each seat class Name=seat row-0 col-0
if ($.isArray(reservedSeat) && $.inArray(seatNo, reservedSeat) != -1) {
className += ' ' + settings.selectedSeatCss;
}
str.push('<li onclick="gettable('+ seatNo+')" class="' + className +" table"+seatNo+ '">'
+'<a title="' + seatNo + '">' + seatNo + '</a>' +
'</li>');
}
}
$('#place').html(str.join(''));
};
var bookedSeats = [5, 10, 25];
init(bookedSeats);
$('.' + settings.seatCss).click(function () {
if ($(this).hasClass(settings.selectedSeatCss)){
alert('This seat is already reserved');
}
else{
$(this).toggleClass(settings.selectingSeatCss);
}
});
First remove the class from all elements, then add it to the selected one.
$('.' + settings.seatCss).click(function () {
if ($(this).hasClass(settings.selectedSeatCss)){
alert('This seat is already reserved');
}
else{
$('.' + settings.seatCss).removeClass(settings.selectingSeatCss);
$(this).addClass(settings.selectingSeatCss);
}
});
Change the else part to:
else{
$(this).toggleClass(settings.selectingSeatCss);
$(".settings.selectingSeatCss").not(this).removeClass('settings.selectingSeatCss');
}
try changing the code in click() event with this one.
$('.' + settings.seatCss).click(function () {
$(this).addClass(settings.selectedSeatCss).siblings(this).removeClass(settings.selectedSeatCss);
});
working Demo. Hope it helps you.
So I'm working on a pre-existing site and I'm trying to add in a point where the code sends out some data. When it gets to my .post() I get the following error:
too much recursion
http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
Line 16
Here's the flow:
Some link text has the following onclick handler:
<a class="lucida_12pxBlueLH16" onclick="changeCipherAdmin(6); return false;" href="#">Keyword: SLEEP</a>
function changeCipherAdmin(num) {
tempHTML = '';
tempHTML += '<select id="select_cipher' + num + '" name="select_cipher' + num + '" class="select_tanbg" onchange="updateKeyFieldsAdmin(this.value,' + num + ',1);">';
tempHTML += ' <option id="option' + num + '_admin1" value="1">Additive</option>';
tempHTML += ' <option id="option' + num + '_admin2" value="2">Affine</option>';
tempHTML += ' <option id="option' + num + '_admin3" value="3">Caesar</option>';
tempHTML += ' <option id="option' + num + '_admin4" value="4">Keyword</option>';
tempHTML += ' <option id="option' + num + '_admin5" value="5">Multiplicative</option>';
tempHTML += ' <option id="option' + num + '_admin6" value="6">Vigenère</option>';
tempHTML += '</select>';
document.getElementById('admin_cipher' + num).innerHTML = tempHTML;
document.getElementById('option' + num + '_admin' + ciphers[num]).selected = true;
updateKeyFieldsAdmin(ciphers[num], num, 0);
}
Based on that it runs the following function
function updateKeyFieldsAdmin(cipherNum, selectNum, resetNum) {
//tempHTML=''+possible_ciphers[cipherNum]+'';
//document.getElementById('admin_cipher'+selectNum).innerHTML=tempHTML;
if (resetNum == 0) {
keyA = keysA[selectNum];
keyB = keysB[selectNum];
}
if (cipherNum == 1) {
//0-25
//change letter to number, add encryption key (two characters?), reduce mod 26
//additive: use a:number
if (resetNum == 1) {
keyA = "";
keyB = "";
}
tempHTML = '<strong class="helvetica11pxTanB">Key (0-25)</strong> <input type="text" id="key_a' + selectNum + '" maxlength="2" class="form_field11px" style="width:19px; height:12px; text-align:right; color:#000000;" value="' + keyA + '" onkeyup="checkKeysAdmin(1,' + selectNum + '); return false;" autocapitalize="off" autocorrect="off" />';
}
else if (cipherNum == 6) {
//vigenere: use a:word--26 letters or less
if (resetNum == 1) {
keyA = "";
keyB = "";
}
tempHTML = '<strong class="helvetica11pxTanB">Keyword</strong> <input type="text" id="key_a' + selectNum + '" maxlength="26" class="form_field11px" style="width:99px; height:12px; text-align:right; color:#000000;" value="' + keyA + '" onkeyup="checkKeysAdmin(event,6,' + selectNum + '); return false;" autocapitalize="off" autocorrect="off" />';
}
document.getElementById('admin_key' + selectNum).innerHTML = tempHTML;
if ((cipherNum == 2 || cipherNum == 5) && !isNaN(keyA) && keyA != "") {
//update select field
if (cipherNum == 2) {
$('#key_a' + selectNum).val(keyA);
}
else {
for (i = 1; i < odd_nums_prime26.length; i++) {
if (keyA * 1 == odd_nums_prime26[i]) {
document.getElementById('key_a' + selectNum).selectedIndex = i;
document.getElementById('option' + selectNum + '_mult' + i).selected = true;
break;
}
}
}
}
if (resetNum == 1) {
checkKeysAdmin(cipherNum, selectNum);
}
}
Which then calls the below:
function checkKeysAdmin(e, cipherNum, row) {
encrypt_ready = true;
if (encrypt_ready == true) {
//keyA and keyB should already be updated...so:
keysA[row] = keysA;
keysB[row] = keysB;
ciphers[row] = cipherNum;
ciphertext[row] = encryptTextAdmin(plaintext[row], cipherNum);
document.getElementById('cipher' + row).innerHTML = ciphertext[row];
// This is my code where Im trying to send my data out
if (e.keyCode == 13 ) {
alert( 'here2' );
$.post('/challenges/save.php', { action:'updateJokeMessage',
messageId:message_ids[row],
joke:message_text[row],
punchline:plaintext[row],
encryptedPunchline:ciphertext[row],
cipherId:cipherNum,
keyA:keysA[row],
keyB:keysB[row]
});
alert( 'Done' );
}
return;
}
else {
//alert("not ready to encrypt");
document.getElementById('cipher' + row).innerHTML = '';
}
// me trying to stop the recursion
event.stopPropagation();
}
I've tried adding in a call back and putting in event.stopPropagation or returning etc. But can't figure out why. Any thoughts/help would be appreciated.
So it ended up being a var typo:
keysA[row] = keysA;
keysB[row] = keysB;
Which was basically assigning the object to one of it's elements, which caused the recursion when jquery tried to process that.
I strongly suspect that your problem is here:
keysA[row] = keysA;
keysB[row] = keysB;
You're making a circular structure, and jQuery is losing its mind when it's trying to trace its way through the parameter object.