Hi,

I'd like to reload a component when an event (dble click) occurs on client 
side (browser) from another component :

I am not able to solve on my own those issues using the code below :
- when setting ajax = True to second component LOAD, the script do not 
provide the sid anymore.
- make the ajax call reload the first form

I have a main page made of 2 components : one form and one grid :

Main page view is :

{{extend 'layout.html'}}
<div id="target" hidden="true"></div>
{{ =LOAD('default','army_header.load', ajax=True , ajax_trap=False , 
target='army_header') }}
{{ =LOAD('default','cards_list.load', ajax=False  ,ajax_trap=False, 
target='cards_list', vars={'mode':'edit'}) }} 
<script>
// catch Id of selected and double clicked row card
jQuery(document).ready(function() { 
        
jQuery('tr.w2p_even.even.with_id,tr.w2p_odd.odd.with_id').dblclick(function() 
{
        var sid =  jQuery(this).prop('id');
        ajax('on_card_selected?card_id='+sid, [] ,'army_header') ;        
                }
                                                                            
) ;
                                    }
                        );
</script> 

army_header.load view is : 
<hr>
{{=formarmy}}

cards_list.load view is :
<hr>
{{=formcards}}

The controller :

@auth.requires_login()    
def army_detail(): 
    """Page composed of 2 components """ 
    
    some_stuff()
    
    army_header()
    
    cards_list()
    
    return dict()

@auth.requires_login()
def army_header():
    
    some_stuff()
          
    form = SQLFORM(db.myarmy )
    
    # Mode vars unknown : create army 
    if form.process(keepvalues=True).accepted:
          
        update_db()
      
    return dict(formarmy=form)
  
@auth.requires_login()
def cards_list():
        
    form = SQLFORM.grid(db.cards)

    return dict( formcards=form)
   
    
@auth.requires_login()
def on_card_selected():
            
    # Load session variables :
    card_id = session.card_id = int(request.vars.card_id)
    
    some_stuff() 
    
    # want to refresh component : 
    army_header()  # 

Thanks.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to