We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

eventListener return false

Home Forums Puzzles eventListener return false

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #58728
    rebuhleiv
    Participant

    Hello!

    I have a simple puzzle.

    When clicking on the button, a hash “#” is added to the URL (because the event does no e.preventDefault() or return false;.

    Combining with execution of a custom js function “return false” does also not work.

    How to suppress the “#” when using only puzzle event listeners?

    Attachments:
    You must be logged in to view attached files.
    #58730
    kdv
    Participant

    show the link to this app. suppose your button with id _001_button_002 has two or more event listeners…

    #58731
    rebuhleiv
    Participant

    No other event listeners are present.

    This also makes sense, since no event.preventDefault() is present in visual_logic.js:

    eventHTMLElem('click', '_001_button_002', true, function(event) {
      tweenCamera('Camera.001', 'Cube.002', 1, function() {}, 1);
    });

    I got it working with this cumbersome workaround (see the attached file).

    • This reply was modified 1 month, 3 weeks ago by rebuhleiv.
    • This reply was modified 1 month, 3 weeks ago by rebuhleiv.
    Attachments:
    You must be logged in to view attached files.
    #58841

    Hi rebuhleiv,

    Is your button an < a > element? If it has its href attribute set to “#”, then clicking the link will add “#” to the URL. If that’s the case then the solution is to use other elements like < button > or < div > (that don’t have such default behavior and therefore won’t need event.preventDefault()). Otherwise, you don’t have direct access to the event in puzzles and can’t do much about it, other than using the workaround you already implemented.

    Co-founder and lead developer at Soft8Soft.

    #58842
    rebuhleiv
    Participant

    Thanks for your answer. Indeed, a button-tag instead of an a-tag is also a good solution. Thanks!

    • This reply was modified 1 month, 3 weeks ago by rebuhleiv.
    • This reply was modified 1 month, 3 weeks ago by rebuhleiv.
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.