0

In my web app I want checkbox to control display or not table column. I had put jquery-2.1.1.js file in ROOT_OF_WEBAPP/WEB/JS/. I need code for show()/hide() column and how include that .js file in current twig. This don't work:

<script type="text/javascript">
    $(document).ready(function() {
        $("jmbg_ch").click(function(event) {
            if ($(this).is(":checked"))
                $(".jmbg_column").show();
            else
                $(".jmbg_column").hide();
       });
    });
</script>

1 Answer 1

1

You have a mistake in your jQuery selector $("jmbg_ch"). If you need to bind click action to the element with id jmbg_ch you need to use sharp symbol: $("#jmbg_ch").

Also it is not good to place your js in the web/js folder. You can put it in Resources/public/js folder of your bundle. Then you just need to run php app/console assets:install --symlink and all your assets from Resources/public/js will be available under web/bundles/yourbundlename/js.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.