Effect.SlideUp is too slow--next statement executes immediately

  • Thread starter nolo contendere
  • Start date
N

nolo contendere

the alert message appears before the Effect.SlideUp even begins. How
can I ensure that the SlideUp completes before executing the next
statement? I've tried setTimeout, and I can kind of get it to work,
but that seems very kludgy, and may not work in all cases.

TIA


=====================
function add_entry( id ) {
var row = $(id).insertRow( journal_rows++ );
var cell0 = row.insertCell(0);
cell0.width="150px";
cell0.innerHTML = "<div id=div_entry" + journal_rows + "
style='display: none;' >Journal Entry " + journal_rows + ":<img src='/
images/notes.gif'>" +
"<textarea id=txt" + journal_rows + " name=txt"
+ journal_rows + " cols=64 rows=5 ></textarea></div>";
Effect.SlideDown('div_entry' + journal_rows);
}

function delete_entry( id, force ) {
if ( journal_rows < 2 ) {
return;
}
if ( force ) {
$(id).deleteRow( --journal_rows );
}
else {
if ( confirm('want to delete journal row: ' + journal_rows +
'?' ) ) {
// The delete happens too fast, tried
setTimeout("deleteRow", 1000), but breaks...
Effect.SlideUp('div_entry' + journal_rows);
alert( 'id: ' + id);
$(id).deleteRow(--journal_rows);
// setTimeout("$(id).deleteRow(--journal_rows)", 2000);
}
}
}
 
S

SAM

nolo contendere a écrit :
the alert message appears before the Effect.SlideUp even begins.

What is Effect.SlideUp() ?
Where is it defined ?
Does it return something in end of job ?
How can I ensure that the SlideUp completes before
executing the next statement?

giving a new special argument to Effect.SlideUp() ?
to fire in end of slide the row's deleting.
I've tried setTimeout, and I can kind of get it to work,
but that seems very kludgy, and may not work in all cases.

=====================
function add_entry( id ) {
var row = $(id).insertRow( journal_rows++ );
var cell0 = row.insertCell(0);
cell0.width="150px";
cell0.innerHTML = "<div id=div_entry" + journal_rows + "
style='display: none;' >Journal Entry " + journal_rows + ":<img src='/
images/notes.gif'>" +
"<textarea id=txt" + journal_rows + " name=txt"
+ journal_rows + " cols=64 rows=5 ></textarea></div>";
Effect.SlideDown('div_entry' + journal_rows);
}

function delete_entry( id, force ) {
if ( journal_rows < 2 ) {
return;
}
if ( force ) {
$(id).deleteRow( --journal_rows );
}

else {
if (confirm('want to delete journal row: '+journal_rows+'?') ) {
Effect.SlideUp('div_entry' + journal_rows);
setTimeout( function() {
$(id).deleteRow(--journal_rows);
}, 2000);
}
}
}

or ... :

else {
if(confirm('want to delete journal row: '+journal_rows+'?') ) {
Effect.SlideUp('div_entry' + journal_rows);
var this_journal_row = --journal_rows;
setTimeout('$('+id+').deleteRow('+this_journal_row+')', 2000);
}
}
}


but ... perhaps ... :

else {
if (confirm('want to delete journal row: '+journal_rows+'?') ) {
while(!Effect.SlideUp('div_entry' + journal_rows)) '';
$(id).deleteRow(--journal_rows);
}
}
}
 
S

s0lnic

SAM said:
nolo contendere a écrit :

What is  Effect.SlideUp() ?
Where is it defined ?
Does it return something in end of job ?

It's from script.aculo.us JS effects library.
 
N

nolo contendere

Use afterFinish callback


This worked! Thanks so much!

Effect.SlideUp('div_entry' + journal_rows, { afterFinish:
function () { $(id).deleteRow(--journal_rows) } } );
 
T

Thomas 'PointedEars' Lahn

s0lnic said:
It's from script.aculo.us JS effects library.

And hopefully the fact that at least two regulars of this newsgroup did not
know that has caused both of you to think in the right direction for a change.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top