Search code examples
jqueryajaxjquery-eventspreventdefault

e.preventDefault() doesn't seem to act like it is supposed to


I have a small little widget to show the weather on the sidebar of this page http://jbm.utad.pt/testes/equipa.php

As soon as the document is ready it shoots a city name by AJAX to processa-tempo.php that populates a div in my main page:

<div id="exibe-tempo"></div>

The accordion is used to show the Forecast and to Choose different cities and here comes the problem. The code is a bit long to post here so I made this: http://jsfiddle.net/jZjQy/1/

It has the jQuery that is inside equipa.php and the markup that processa-tempo.php returns.

If I click in a new city ... it doesn't acts as it is supposed (refresh the div "exibe-tempo")

I really don't know that much to debug this ... any help? it would be greatly appreciated.


Solution

  • I checked your page again and probably found the error. You add the links which containing the cities, dynamically. But the onclick bind comes on page load event. so you have to apply a live listener for this event like so:

    $(document).on('click','.cidade',function(event){
    event.preventDefault();