Page repositioning to top causing dialog to shift down or off screen.

Page repositioning to top causing dialog to shift down or off screen.


I'm using the JQuery UI Dialog which upon opening seems to be working
fine. Inside this dialog I have a form, inside which are form elements
with "Add one" functionality, to allow users to enter multiple of a
given field. This is also working fine - except that every time I
click on "Add one" the page repositions to the top of the page,
leaving the dialog where it was lower on the screen, causing a bad
shift and sometimes causing the dialog to go "below the fold". Is
there any way to do this without repositioning the page in the
browser?
Here is the html
<input type="image" src="/static/images/addedit.gif" id="bttn-titles"
value="Add or Edit Titles" class="editbutton"/>
<div id="titles-dialog">
     <h3>Titles</h3>
     <form method="post">
     <div id="formaltitles" class="eff-repeating">
        <div id="formaltitle" class="eff-prototype" style="display: none;
border: 1px solid #CCCCCC; padding: 8px; margin-bottom: 8px;
background: #EEEEEE">
         <label for="input">Select a title:</label>
         <select name="formaltitle_sel" id="formaltitle_sel">
         <option selected="selected">-- Select One --</option>
         </select>
         <br/>
         <a href="#" name="Formal Title" class="eff-remove">Remove</a>
        </div>
        

<a href="#" class="eff-add">&nbsp;Add another title</a><br/>


     </div>
</div>
and the script:
function effAdd()
{
var ret = $(this).map(function () {
var lastcounter;
var myrepeating = $(this).parents(".eff-repeating")[0];
var myproto = $(myrepeating).children(".eff-prototype")[0];
// clone and add appropriate classes
var myclone = $(myproto).clone(true).addClass('eff-
clone').removeClass('eff-prototype').css('display', 'block');
// any clones?
var clones = $(myrepeating).children('.eff-clone');
// counter to append to id's and names:
// either add one to the counter in the last clone or
// use 1 if there are no clones.
if (clones.length == 0) {
lastcounter = 1;
// find all id's and name's and add the counter to them
renumber(myclone, lastcounter);
myclone.insertAfter(myproto);
//$(myproto).parent().append(myclone);
clonefun = $('#' + $(myproto).attr('id').replace(/(_\d)+
$/, "")).data('onClone');
if (clonefun) {
clonefun(myclone);
};
}
else {
var lastind = $(clones[clones.length - 1]).attr('id').match
('.+_([0-9])')[1];
if (lastind != null) {
lastcounter = parseInt(lastind) + 1;
// find all id's and name's and add the counter to them
renumber(myclone, lastcounter);
myclone.insertAfter(clones[clones.length - 1]);
//$(clones[clones.length - 1]).append(myclone);
clonefun = $('#' + $(myproto).attr('id').replace(/(_\d)+
$/, "")).data('onClone');
if (clonefun) {
clonefun(myclone);
};
};
};
return(myclone[0]);
});
return(ret);
};