0

need another help. I was stuck on this "problem" for four days already, it's getting frustrating because the project I'm working on is easy, It should be easy.

Title speaks for Itself. I'll list some things I've tried... Replacing e.preventDefault() for return false and/or e.stopPropagation(), not working. Adding this.submit(); at the end, not working. Tried using new .on syntax instead of .submit, not working. And that's It.

If somebody has any idea, please. Thank you in advance, even for trying.

$("#allRuns").click(function () {
fetchBookmarks();

$("#edit").click(function () {
    $("#container").html('<form id="allForm">' +
        'Distance: <input id="allDistance" type="text"><br>' +
        'Time: <input id="allTime" type="text"><br>' +
        '<input type="submit" value="Edit">' +
        '</form>'
    );
});

$("#allForm").submit(function (e) {
    /* var bookmarks = JSON.parse(localStorage.getItem("bookmarks"));
    for (var i = 0; i < bookmarks.length; i++) {
        if (bookmarks[i].time == time) {
            console.log(bookmarks[i])
        };
    }; */
    console.log("H")
    e.preventDefault();
});
});

For some reason, here on web is weird spacing, hope It make sense. Seems like there Is tab missing. Probably my mistake, still new here and don't know how to use this properly. Basically what I need is to see whatever response in console, console.log("H") doesn't return anything.

In any case. There is a link on GitHub with a right file if that's better for you.

https://github.com/ovy1448/MyRun/blob/master/js/main.js

The problem is at the bottom. If you need to know more, just ask. Thanks again.

Daniel Ovári
  • 15
  • 1
  • 5
  • I'm not sure how your form is setup but it's possible you need to use e.stopPropagation() to keep it from propagating further up the DOM chain. – Nathan Champion Nov 20 '18 at 20:48
  • Nah, not working aswell. Nothing changes, everything is the same. But thank you. – Daniel Ovári Nov 21 '18 at 11:32
  • Duplicate: https://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements – Quentin Nov 21 '18 at 11:42
  • "Tried using new .on syntax" — `on` was introduced in jQuery 1.7 when jQuery was 5 years old. jQuery is now 12 years old. `on` is far, far from "new". – Quentin Nov 21 '18 at 11:44
  • Hey Quentin, the link you provided helped. It was exactly what I needed. Thank you very much, and sorry for the delay. – Daniel Ovári Dec 02 '18 at 12:35

0 Answers0