Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Location
    Sutton-in-ashfield, Notts
    Posts
    117
    Thanks
    7
    Thanked 0 Times in 0 Posts

    return innerHTML oncomplete

    How can i return this innerHTML on complete?

    Code:
    deleteUser: function( id ) {
    
    		elm = $( 'user_' + id );
    
    		Effect.Pulsate( elm, {duration: 1, pulses: 2} );
    		Effect.Fade( elm, {delay: 1, duration: 0.5} );
    
    		new Ajax.Request( 'ajax', {
    
    			method: 'post',
    			parameters: {mode: 'deleteUser', id: id},
    			onComplete: function( transport ) {
    				innerHTML = "<div class=\"good\"></div>";
    			}
    
    		} );
    
    	}
    the fade works but i want to return the div to say deleted successfuly.

  • #2
    New to the CF scene
    Join Date
    Aug 2011
    Location
    Poland
    Posts
    8
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You can't just use innerHTML alone because it is always a property of some DOM element. It means in JavaScript you have to always use someElement.innerHTML = "some new content";.

    To summarize you your code should look something like:
    Code:
    deleteUser: function( id ) {
    
    		elm = $( 'user_' + id );
    
    		Effect.Pulsate( elm, {duration: 1, pulses: 2} );
    		Effect.Fade( elm, {delay: 1, duration: 0.5} );
    
    		var confirmBox = $('confim-box');
    		new Ajax.Request( 'ajax', {
    
    			method: 'post',
    			parameters: {mode: 'deleteUser', id: id},
    			onComplete: function( transport ) {
    				confirmBox.innerHTML = "<div class=\"good\"></div>";
    			}
    
    		} );
    
    	}
    Additionally you need to create a DIV element to hold the confirm message. Place it at top of the table with user list for example.

    Here is the additional HTML I'm talking about - you need to add it to you page source.
    Code:
    <div id="confim-box"></div>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •