Skip to content

Saving Content#14

Open
dineenlauren wants to merge 1 commit into
masterfrom
saving-content
Open

Saving Content#14
dineenlauren wants to merge 1 commit into
masterfrom
saving-content

Conversation

@dineenlauren

Copy link
Copy Markdown
Collaborator

Issue #4

  • Created an "Add Poem" button
  • "Heading" text is saved into a "Saved Items" container

Issue:

  • When "Add Poem" button is clicked, it moves the "Heading" text to the "Saved Items" container, rather than duplicating the text.

Before Save Button:

before-save-btn - copy

After Save Button:

after-save-btn - copy

Comment thread index.html
<!--TEST CODE --------------------------------------------------------->
<div>
<h4>Saved Items</h4>
<ul id="list" class="saved-list"></ul>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Unordered List is where the title of a saved poem goes once a user clicks "Add Poem." But It keeps moving the entire <h2> element from line 103 to this list.

Comment thread index.html
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
<div>
<h2 id="poem">Heading</h2>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id="poem" for this <h2> element

Comment thread js/main.js
let poem = document.getElementById("poem");
let poemName = poem;

li.appendChild(poemName);

@dineenlauren dineenlauren Feb 18, 2019

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that it has something to with my JS here. I don't want to appendChild but I'm not sure how to push a copy of the text to the "saved content" list

Change (poemName) to (poem)

Comment thread js/main.js
function addPoem() {
let ul = document.getElementById("list");
let li = document.createElement("li");
let poem = document.getElementById("poem");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let poem = document.getElementById("poem");
let poem = document.getElementById("poem").cloneNode(true);

Comment thread js/main.js
let ul = document.getElementById("list");
let li = document.createElement("li");
let poem = document.getElementById("poem");
let poemName = poem;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this line. Can delete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant