Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Effect.SlideUp is too slow--next statement executes immediately

Reply
Thread Tools

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

 
 
nolo contendere
Guest
Posts: n/a
 
      11-08-2007
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);
}
}
}

 
Reply With Quote
 
 
 
 
s0lnic
Guest
Posts: n/a
 
      11-08-2007
nolo contendere wrote:

> Effect.SlideUp('div_entry' + journal_rows);


Use afterFinish callback

--
# Regards || piotr[.]solnica[at]gmail[.]com || jid : http://www.velocityreviews.com/forums/(E-Mail Removed) #
# s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #
 
Reply With Quote
 
 
 
 
SAM
Guest
Posts: n/a
 
      11-08-2007
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);
}
}
}
 
Reply With Quote
 
s0lnic
Guest
Posts: n/a
 
      11-09-2007
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 : (E-Mail Removed) #
# s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #
 
Reply With Quote
 
SAM
Guest
Posts: n/a
 
      11-09-2007
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
 
Reply With Quote
 
nolo contendere
Guest
Posts: n/a
 
      11-09-2007
On Nov 8, 6:36 pm, s0lnic <(E-Mail Removed)> wrote:
> 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) } } );



 
Reply With Quote
 
nolo contendere
Guest
Posts: n/a
 
      11-09-2007
On Nov 9, 7:58 am, SAM <(E-Mail Removed)>
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.

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      11-09-2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CDOSYS executes but takes TOO TOO long? JVRudnick ASP General 13 02-28-2008 03:03 PM
if statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
array executes only first rasdj@frontiernet.net Perl 1 03-04-2005 04:23 PM
Posting onto a form after code executes? Rob Meade ASP .Net 5 12-10-2003 04:24 PM
Displaying Progress info to client while ServerSide code executes. Chris Tillotson ASP .Net 2 11-04-2003 09:03 PM



Advertisments