By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,562 Members | 1,219 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,562 IT Pros & Developers. It's quick & easy.

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

P: n/a
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);
}
}
}

Nov 8 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
nolo contendere wrote:
Effect.SlideUp('div_entry' + journal_rows);
Use afterFinish callback

--
# Regards || piotr[.]solnica[at]gmail[.]com || jid : s0****@jabster.pl #
# s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #
Nov 8 '07 #2

P: n/a
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);
}
}
}
Nov 8 '07 #3

P: n/a
SAM wrote:
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 ?
It's from script.aculo.us JS effects library.

--
# Regards || piotr[.]solnica[at]gmail[.]com || jid : s0****@jabster.pl #
# s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #
Nov 9 '07 #4

P: n/a
SAM
s0lnic a écrit :
SAM wrote:
>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 ?

It's from script.aculo.us JS effects library.
Ha! OK. (50ko of compressed code ...!)

So the answer isn't it here :
<http://wiki.script.aculo.us/scriptaculous/show/EffectQueues>
?

--
sm
Nov 9 '07 #5

P: n/a
On Nov 8, 6:36 pm, s0lnic <l...@my.sigwrote:
nolo contendere wrote:
Effect.SlideUp('div_entry' + journal_rows);

Use afterFinish callback

This worked! Thanks so much!

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

Nov 9 '07 #6

P: n/a
On Nov 9, 7:58 am, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
s0lnic a écrit :
SAM wrote:
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 ?
It's from script.aculo.us JS effects library.

Ha! OK. (50ko of compressed code ...!)

So the answer isn't it here :
<http://wiki.script.aculo.us/scriptaculous/show/EffectQueues>
?
I believe that would have worked, although I didn't test it. I used
the afterFinish callback suggested by s01nic.

Nov 9 '07 #7

P: n/a
s0lnic wrote:
SAM wrote:
>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 ?

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
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Nov 9 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.