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

Discussion in 'Javascript' started by nolo contendere, Nov 8, 2007.

  1. 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);
    }
    }
    }
     
    nolo contendere, Nov 8, 2007
    #1
    1. Advertising

  2. nolo contendere

    s0lnic Guest

    nolo contendere wrote:

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


    Use afterFinish callback

    --
    # Regards || piotr[.]solnica[at]gmail[.]com || jid : #
    # s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #
     
    s0lnic, Nov 8, 2007
    #2
    1. Advertising

  3. nolo contendere

    SAM Guest

    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);
    }
    }
    }
     
    SAM, Nov 8, 2007
    #3
  4. nolo contendere

    s0lnic Guest

    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 : #
    # s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #
     
    s0lnic, Nov 9, 2007
    #4
  5. nolo contendere

    SAM Guest

    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
     
    SAM, Nov 9, 2007
    #5
  6. On Nov 8, 6:36 pm, s0lnic <> 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) } } );
     
    nolo contendere, Nov 9, 2007
    #6
  7. On Nov 9, 7:58 am, SAM <>
    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.
     
    nolo contendere, Nov 9, 2007
    #7
  8. 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
     
    Thomas 'PointedEars' Lahn, Nov 9, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay McGavren
    Replies:
    11
    Views:
    1,187
    Alan Krueger
    Jan 16, 2006
  2. Deniz Bahar
    Replies:
    2
    Views:
    518
    Andrey Tarasevich
    Mar 9, 2005
  3. JVRudnick

    CDOSYS executes but takes TOO TOO long?

    JVRudnick, Feb 20, 2008, in forum: ASP General
    Replies:
    13
    Views:
    305
    JVRudnick
    Feb 28, 2008
  4. Kevin Lucas

    jquery question on slideUp fadeIn and show

    Kevin Lucas, Sep 13, 2009, in forum: Javascript
    Replies:
    33
    Views:
    442
    Gregor Kofler
    Sep 19, 2009
  5. iMath
    Replies:
    1
    Views:
    167
    Steven D'Aprano
    Mar 15, 2013
Loading...

Share This Page