Javascript does't work at first but works on second, third, etc. times

cobanja

Javascript does't work at first but works on second, third, etc. times.

;(function ( $, window, document, undefined ) {

$variation_form = $( '.variations_form');

$variation_form.on( 'show_variation', function( event, variation ){

    if ( variation.variation_description ) {
        $( '.variation-description p').html( variation.variation_description );
    }
})
.on( 'reset_image', function () {

    $('.variation-description p').html('');
});

})( jQuery, window, document );

Tech Savant

You need something to fire the events.....

$(".myselector").on('click', function() {
    $variation_form.trigger('show_variation');
});

Working Fiddle (again) :P Full code below...

(function($){
    $(function(){  

        $variation_form = $('.variations_form');

        $variation_form.on('show_variation', function (event, variation) {                
            if (variation.variation_description) {
                $('.variation-description p').html(variation.variation_description);
            }
        });

        $variation_form.on('reset_image', function () {
            $('.variation-description p').html('');
        });

        $(".myselector").on('click', function() {
            $variation_form.trigger('show_variation');
        });
     });
 })(jQuery); 

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Javascript does't work at first but works on second, third, etc. times

분류에서Dev

Why does the first assert work, but not the second?

분류에서Dev

Why does the first one work and the second one not work? Global and Private variable declaration

분류에서Dev

printing second variable as many times as first variable

분류에서Dev

Twitter doesn't give access on trying to post tweet for second time without exiting fragment but works fine on posting tweet for first time

분류에서Dev

Why is the second execution of this combinator 10 times faster than the first?

분류에서Dev

Javascript .getAttribute() works but .attr() does not

분류에서Dev

How does this work in javascript

분류에서Dev

My code is working and the first line is displaying correctly but the second line is concatenated with the first line etc

분류에서Dev

Why is does this Toast(Android Studio) works only at the second click

분류에서Dev

cp doesn't work in script but works in terminal

분류에서Dev

How to order the same set of records two times, the second ordering performing independently from the first one?

분류에서Dev

How does "newElements" work in Javascript?

분류에서Dev

toggleClass() doesn't work after first time

분류에서Dev

Although my ISR handler works perfectly, IRQ handler does not work

분류에서Dev

Animation from 0 to 1 opacity does not work in FireFox but works in Chrome

분류에서Dev

Function overloading in C++. Does not work with float, works with double

분류에서Dev

Libertine container sound does not work on one machine, works on another

분류에서Dev

JavaScript/jQuery reference to a third party website works locally, not when hosted on godaddy run site (404 error)

분류에서Dev

Alias to attempt mounting multiple times doesn't work correctly

분류에서Dev

first parent ul and first li doesn't work properly

분류에서Dev

Java split() method won't work a second time

분류에서Dev

Can't get second level of a CSS/html dropdown menu to work

분류에서Dev

Can't get my second network card to work on ubuntu server

분류에서Dev

UITabBar appearance setSelectionIndicatorImage does not work on first launch iOS7

분류에서Dev

How Does Initalizing a Javascript Modal Work in Materializecss?

분류에서Dev

Why does this C code not work in JavaScript?

분류에서Dev

Javascript null or empty control does not work

분류에서Dev

Why does this C code not work in JavaScript?

Related 관련 기사

  1. 1

    Javascript does't work at first but works on second, third, etc. times

  2. 2

    Why does the first assert work, but not the second?

  3. 3

    Why does the first one work and the second one not work? Global and Private variable declaration

  4. 4

    printing second variable as many times as first variable

  5. 5

    Twitter doesn't give access on trying to post tweet for second time without exiting fragment but works fine on posting tweet for first time

  6. 6

    Why is the second execution of this combinator 10 times faster than the first?

  7. 7

    Javascript .getAttribute() works but .attr() does not

  8. 8

    How does this work in javascript

  9. 9

    My code is working and the first line is displaying correctly but the second line is concatenated with the first line etc

  10. 10

    Why is does this Toast(Android Studio) works only at the second click

  11. 11

    cp doesn't work in script but works in terminal

  12. 12

    How to order the same set of records two times, the second ordering performing independently from the first one?

  13. 13

    How does "newElements" work in Javascript?

  14. 14

    toggleClass() doesn't work after first time

  15. 15

    Although my ISR handler works perfectly, IRQ handler does not work

  16. 16

    Animation from 0 to 1 opacity does not work in FireFox but works in Chrome

  17. 17

    Function overloading in C++. Does not work with float, works with double

  18. 18

    Libertine container sound does not work on one machine, works on another

  19. 19

    JavaScript/jQuery reference to a third party website works locally, not when hosted on godaddy run site (404 error)

  20. 20

    Alias to attempt mounting multiple times doesn't work correctly

  21. 21

    first parent ul and first li doesn't work properly

  22. 22

    Java split() method won't work a second time

  23. 23

    Can't get second level of a CSS/html dropdown menu to work

  24. 24

    Can't get my second network card to work on ubuntu server

  25. 25

    UITabBar appearance setSelectionIndicatorImage does not work on first launch iOS7

  26. 26

    How Does Initalizing a Javascript Modal Work in Materializecss?

  27. 27

    Why does this C code not work in JavaScript?

  28. 28

    Javascript null or empty control does not work

  29. 29

    Why does this C code not work in JavaScript?

뜨겁다태그

보관