user1888260
user1888260

Reputation: 47

jQuery not working correctly on click, only one element

I am having trouble getting this to work correctly, you can see the code below, it seems like it is only working for one link, it will just load index.php?act=old...

$(document).ready(function(){

        $("#example").dialog({modal: true});
        $("#example").dialog({width: 500});

        $('#newProject').click(function(){
            $('#dialogContent').load('index.php?act=new');
        });

        $('#oldProject').click(function(){
            $('#dialogContent').load('index.php?act=old');
        });

    });

and the HTML

<div id="example" title="Create new project or open old project?" style="display:none">
<div id="dialogContent">
Would you like to create a new calculation or open and edit and old calculation?<br /><br />
<a href="#" id="oldProject">Open Old Calculation</a><br /><br /><a href="#" id="newProject">Create New Calculation</a>
</div>
</div>

Upvotes: 1

Views: 78

Answers (1)

ymz
ymz

Reputation: 6914

try to disable the default behavior of the link:

$('#newProject').click(function(event)
{
     event.preventDefault();
     $('#dialogContent').load('index.php?act=new');
});

$('#oldProject').click(function(event)
{
      event.preventDefault();
      $('#dialogContent').load('index.php?act=old');
});

Upvotes: 1

Related Questions