0

I am developing a web site using Sympfony2. In fact, I created a twig file called "tes2.html.twig". Its code is as below:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="{{asset('bundles/moslemtest/phptest/bootstrap.min.css')}}"/>
    <script src="{{asset('bundles/moslemtest/phptest/bootstrap.min.js')}}" type="text/javascript"></script>
    <script src="{{asset('bundles/moslemtest/src/jquery.min.js')}}" type="text/javascript"></script>
</head>
<body> 
        <div class="btn-group">
        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
            <input type="image"  id="notifications" alt="notifications" src="{{asset('bundles/moslemtest/phptest/notifications.jpg')}}"/>
        </button>
        <ul class="dropdown-menu" role="menu">
            <li><span>hello</span></li>
        </ul>
    </div>
</body>

When I see the output of that file, I see the button below on the screen:

enter image description here

The issue is when I click on that button no item appears despite I checked the paths out in the code above. By the way, you can have a look at the screenshot below to get sure about that:

enter image description here

As you can notice above, I respected the path of each source file (I mean: bootstrap.min.css, bootstrap.min.js, jquery.min.js and notifications.jpg). So my question is what is the error in my code ?

3
  • Get your code working with hard coded URLS in the HTML first. Then once it works on the client side replace those URLs with ones generated by Symfony2 Commented May 30, 2014 at 9:11
  • Use your browsers dev tools to figure out which URLs aren't working Commented May 30, 2014 at 9:11
  • @Jon Winstanley: yes I tried that using HTML and it worked!!..I can't understand why that code doesn't work in Symfony2!!! Commented May 30, 2014 at 9:17

1 Answer 1

0
  • open firebug and select console
  • hit or refresh the page then look for error loading java script and css

i believe these are missing in your env, that is because when i copy and paste your code here - it works!

http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_dropdown-menu&stacked=h

Or try the reverse by replacing your code with the working code here

http://www.w3schools.com/bootstrap/bootstrap_dropdowns.asp

, if this does not work you know it is your required javascript or css for bootstrap to work does not load.

  • be sure your page load with no error by looking at the console tab of firebug.
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.