OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – HTML, JavaScript, CSS, Design Questions Simple JS functions/handlers and Oro's frontend

This topic contains 5 replies, has 2 voices, and was last updated by  Stepan Yudin 7 years, 2 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34679

    Stepan Yudin
    Participant

    Good day everyone

    I totally cannot figure out how to solve my problem.
    To put it briefly: my JS function fires multiple times.

    I put JS handlers directly into my templates
    Lets consider the following simple example.

    So, each time i open this page – js handlers applies again and when i click a button i recieve several messages in console.
    I understand why this happens – frontend doesnt know when to dispose my JS functions and they stay alive.

    What is the simplest way to solve this? Im totally dumb in modern JS frontend. I saw manual how to define components, but i dont need to define template of component. Only js handlers to intercept click on some elements with some classes.
    In fact all i need is to create some click handlers (for special CSS classes) and correctly apply them only at specified pages (not across the whole application)


    Docker environment for Symfony2/OroCRM/OroBAP development on Windows platform
    https://github.com/stepansib/sf-oro-docker

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #34680

    Stepan Yudin
    Participant

    Maybe the simplest example of solution…


    Docker environment for Symfony2/OroCRM/OroBAP development on Windows platform
    https://github.com/stepansib/sf-oro-docker

    #34681

    Mike Kudelya
    Participant

    Hi Stepan

    Try the following code:

    #34682

    Stepan Yudin
    Participant

    Hi Mike)
    Thank you, but this is a particular solution. This code will not work for elements added dynamically


    Docker environment for Symfony2/OroCRM/OroBAP development on Windows platform
    https://github.com/stepansib/sf-oro-docker

    #34683

    Mike Kudelya
    Participant

    Hi

    You should use view js. I show you some links. Initialize your view in twig (customerType you can skip). Here is view and you should register it in requirejs.yml.

    Use render() function for binding and dispose() for unbinding. Do not forget run:

    #34684

    Stepan Yudin
    Participant

    Mike! You’ve made my day, thank you a lot)
    Just one thing i changed: render() method was never invoked, so i used initialize()


    Docker environment for Symfony2/OroCRM/OroBAP development on Windows platform
    https://github.com/stepansib/sf-oro-docker

Viewing 5 replies - 1 through 5 (of 5 total)

The forum ‘OroPlatform – HTML, JavaScript, CSS, Design Questions’ is closed to new topics and replies.

Back to top