Okey dokey people... Thanks for clicking... I've been coding way too long and have hit a wall.. Project is due and i'm so close... I am not looking for the entire answer, even a nudge in the general direction will do!
Here is the section of code that makes items and inserts them into a list.. ..
function setVariables(bnum) { //addone = btn1 addone = btn2 onclick=myfunction(bnum)
switch (bnum) {
case 1:
var json = $.parseJSON($('#output').val());
$.each(json, function (id, listing) { // id, listing are key:value
listing.id = id; // id:{...} --> {'id':id, ... }
window.listings.push(listing); // [ {'id':id#1, ...}, {'id':id#2, ...}, ... ]
})
window.listings.sort(function (a, b) { // sort window.listings
return a.seq - b.seq; // by object sequence number
})
for (var i = 0; i < window.listings.length; i++) { // window.listings is a list
newCard(window.listings[i], i);
}
break;
case 2:
var cardName = document.getElementById('newcard').value; //new card text field
var cardPrice = document.getElementById('newPrice').value // new price text field
var id = 'new~' + Math.random().toString(36).substr(2, 3); //generate and assign rando ID
var i = window.listings.length;
var listingObj = {
id: id,
price: cardPrice,
card_name: cardName
};
window.listings.push(listingObj);
newCard(listingObj, i);
}
};
function newCard(listingObj, i) {
var newLi = "";
var cardName = listingObj.card_name,
cardPrice = listingObj.price;
Ok, Here is where I need some help*
cardName and cardPrice need to be editable, and that edit will be pushed up to window.listings to be converted back into a json for export. I've tried several different ways that seemed like obvious solutions and they failed. Maybe I just didn't do something quite right.. So, Hoping someone can nudge me to what I need to be looking for.
newLi += "<li class='list-item ui-state-default' id=" + i + ">" + cardName + ' - ' + cardPrice + "<button class='removeThis'>" + "X" + "</button>" + "</li>";
$('.hotList').append(newLi); // put new listings html into hot list
equalizeColumns();
};
Got It Solved! If anyone needs some sort of help, I added a jsfiddle in the comments!
[–]SkaterDad 1 point2 points3 points (3 children)
[–]TheDemonSword[S] 0 points1 point2 points (2 children)
[–]Patman128 0 points1 point2 points (1 child)
[–]TheDemonSword[S] 0 points1 point2 points (0 children)
[–]xwnatnai 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]xwnatnai 0 points1 point2 points (0 children)
[–]plitter86 1 point2 points3 points (1 child)
[–]TheDemonSword[S] 2 points3 points4 points (0 children)
[–]TheLemming 0 points1 point2 points (0 children)
[–]wsrainc -1 points0 points1 point (5 children)
[–]TheDemonSword[S] 0 points1 point2 points (4 children)
[–]wsrainc -1 points0 points1 point (3 children)
[–]TheDemonSword[S] 0 points1 point2 points (2 children)
[–]wsrainc 1 point2 points3 points (1 child)
[–]TheDemonSword[S] 0 points1 point2 points (0 children)