MarkyAaronYoung / bear-watcher

0 stars 1 forks source link

Help understanding my own code #15

Open MarkyAaronYoung opened 4 years ago

MarkyAaronYoung commented 4 years ago

https://github.com/MarkyAaronYoung/bear-watcher/blob/c2439eaa711532c2e03ba0a3a222c02eff3e3ce3/Javascripts/Components/river.js#L4-L23

MarkyAaronYoung commented 4 years ago

I was finally able to get my individual bear cards to printToDom this last night/this morning but only after I used two jquery value selectors: $('#bear-name').val(); $('#bear-img').val();. which itself was a suggestion. I understand what everything else on the page is doing but I don't see why I need to select these elements again when I've already selected them in the same fashion in my bearData (see below)?

const addBear = (e) => {
  e.preventDefault();
  let newBear = {
      // name: document.querySelector('#').value,
      // imageUrl: document.querySelector('#').value,
      name: $('#bear-name').val(),
      imageUrl: $('#bear-img').val(),
  }
  console.log(newBear);
  bears.push(newBear);
  river.createBearCard();
};
luketlancaster commented 4 years ago

Seems to work fine for me without them? So I don't think you need them at all