jQuery trigger('click') not working with Jasmine-jquery

后端 未结 1 1745
小鲜肉
小鲜肉 2020-12-11 11:29

This is my test code:

describe(\"Login\", function(){
    beforeEach(function(){
        loadFixtures(\'login-fixture.html\');
    })

    it(\"should enable         


        
相关标签:
1条回答
  • 2020-12-11 11:56

    Without seeing the rest of the code, I'm assuming the "login-fixture.html" contains the "#remember" checkbox. If so, it's loading after the DOM loads. Meaning that the 'click' event you want assigned will only apply to previously loaded elements. The jQuery on() event will assign any event you want to newly loaded elements. You might want to try adding a on() event to that id. Something like:

    $(function(){
        $('#remember').on('click', function(){
            if($('#remember').is(':checked')){
                $('#keepIn').checkboxradio('enable');
            }
        });
    });
    

    Hope that helps.

    See: http://api.jquery.com/on/

    0 讨论(0)
提交回复
热议问题