ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

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

  • Creator
    Topic
  • #24917
    Stepan Yudin
    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
  • #24919
    Stepan Yudin
    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

    #24936
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi Stepan

    Try the following code:

    #24937
    Stepan Yudin
    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

    #24938
    Mike Kudelya
    Mike Kudelya
    Oro Core

    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:

    #25011
    Stepan Yudin
    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)

You must be logged in to reply to this topic.