I have more problem...

ajax=True don't work!

ajax=False work fine with the Storage(vars) correction in compileapp.py
fix...

ajax=False not working without a specific create_fvte.load view (base on
copy and change name of generic view)... Where is the patch so I could test
if it fix the problem...

But, the problem now is that ajax=True not working at all under 1.97.1 and I
just test with 1.96.4 and *&?%$ it stop working...

I am a dumb of component...

If someone would help to troubleshout here my code under 1.97.1 :

VIEWS :

CREATION
{{extend 'layout_form.html'}}

<style type="text/css" title="currentStyle">
@import
"{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/themes/base/jquery.ui.all.css')}}";
</style>

<div class="demo">
<br/>
<br/>
<br/>
<div id="tabs">
    <ul>
        <li><a href="#tabs-1">{{=T('folder').capitalize()}}</a></li>
        <li><a href="#tabs-2">{{=T('volume').capitalize()}}</a></li>
        <li><a href="#tabs-3">{{=T('tome').capitalize()}}</a></li>
        <li><a href="#tabs-4">{{=T('report').capitalize()}}</a></li>
    </ul>
    <div id="tabs-1">
    <br/>

{{=LOAD(c='ref',f='create_fvte',args='ref_fnaregistry',extension='load',ajax=True,ajax_trap=False,target='one')}}
    </div><!-- tabs-1 -->
    <div id="tabs-2">
    <br/>

{{=LOAD(c='ref',f='create_fvte',args='ref_vregistry',extension='load',ajax=True,ajax_trap=False,target='two')}}
    </div><!-- tabs-2 -->
    <div id="tabs-3">
    <br/>

{{=LOAD(c='ref',f='create_fvte',args='ref_tregistry',extension='load',ajax=True,ajax_trap=False,target='three')}}
    </div><!-- tabs-3 -->
    <div id="tabs-4">
    <br/>

{{=LOAD(c='ref',f='create_fvte',args='ref_eregistry',extension='load',ajax=True,ajax_trap=False,target='four')}}
    </div><!-- tabs-4 -->
</div><!-- tabs -->

</div><!-- End demo -->

<script type="text/javascript" charset="utf-8"

src="{{=URL('static','plugin_added/jquery-ui-1.8.13.custom/js/jquery-1.5.1.min.js')}}">
</script>
<script type="text/javascript" charset="utf-8"

src="{{=URL('static','plugin_added/jquery-ui-1.8.13.custom/development-bundle/ui/minified/jquery.ui.core.min.js')}}">
</script>
<script type="text/javascript" charset="utf-8"

src="{{=URL('static','plugin_added/jquery-ui-1.8.13.custom/development-bundle/ui/minified/jquery.ui.widget.min.js')}}">
</script>
<script type="text/javascript" charset="utf-8"

src="{{=URL('static','plugin_added/jquery-ui-1.8.13.custom/development-bundle/ui/minified/jquery.ui.tabs.min.js')}}">
</script>
<script>
$(function() {
    //var $tabs =
    $( "#tabs" ).tabs();
    //$tabs.tabs('select',  {{=session.tab_pos}});
    //    return false;
});
</script>

CREATE_FVTE.html
{{extend 'layout.html'}}

CREATE_FVTE.load (generic.load copy)
{{'''
# License: Public Domain
# Author: Iceberg at 21cn dot com

With this generic.load file, you can use same function to serve two
purposes.

= regular action
- ajax callback (when called with .load)

Example modified from http://www.web2py.com/AlterEgo/default/show/252:

def index():
    return dict(
        part1='hello world',
            part2=LOAD(url=URL(r=request,f='auxiliary.load'),ajax=True))

def auxiliary():
    form=SQLFORM.factory(Field('name'))
    if form.accepts(request.vars):
        response.flash = 'ok'
        return dict(message="Hello %s" % form.vars.name)
    return dict(form=form)

Notice:

- no need to set response.headers['web2py-response-flash']
- no need to return a string
even if the function is called via ajax.

'''}}{{if
len(response._vars)==1:}}{{=response._vars.values()[0]}}{{else:}}{{=BEAUTIFY(response._vars)}}{{pass}}

CONTROLLER :

# Tabs system for registry tables need creation() and create_fvte()
functions
#@auth.requires_login()
def creation():
    """
    Empty function for make it works the jQuery tabs plugin for ref_*
tables.
    See the create_fvte() function docstring for more details.
    creation() and create_fvte() functions work in conjonction.
    """
    a = None
    return dict(a=a)

#@auth.requires_login()
def create_fvte():
    """
    This function works in conjonction of creation() function. Both
functions
    are required to make works the Tabs System for registry tables.
    create_fvte() is used to allow the usage of registry tables as
component
    to be loaded into creation() function. There is jQuery UI Tabs plugin
    script in the view of the creation() function.

    To redirect between the differents tabs programmatically we use the
tab_pos
    session variable to store the index of the tabs on which the user has to
be
    redirected to. We check if the create_fvte() function is call by GET
    (vs POST) to determine when to initialise the pos_tab variable to zero.
    The pos_tab vars is embeded into the jQuery code of the script like this
    {{session.tab_pos}} in the view of creation() function.
    """
    #if request.env.request_method == 'GET':
    #    session.tab_pos=0
    table = request.args(0)
    if auth.has_membership(auth.id_group('admin')):
        crud.settings.formstyle='divs'
        form = crud.create(db[table])
        for i in range(0,len(form[0])):
            if len(form[0][i][2][0]) > 0:
                form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
            del(form[0][i][2])
    elif auth.has_membership(auth.id_group('technician')):
        crud.settings.formstyle='divs'
        form = crud.create(db[table])
        for i in range(0,len(form[0])):
            if len(form[0][i][2][0]) > 0:
                form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
            del(form[0][i][2])
    elif auth.has_membership(auth.id_group('coordinator')):
        crud.settings.formstyle='divs'
        form = crud.create(db[table])
        for i in range(0,len(form[0])):
            if len(form[0][i][2][0]) > 0:
                form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
            del(form[0][i][2])
    elif auth.has_membership(auth.id_group('technician_c')):
        crud.settings.formstyle='divs'
        form = crud.create(db[table])
        for i in range(0,len(form[0])):
            if len(form[0][i][2][0]) > 0:
                form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
            del(form[0][i][2])
    elif auth.has_membership(auth.id_group('coordinator_c')):
        crud.settings.formstyle='divs'
        form = crud.create(db[table])
        for i in range(0,len(form[0])):
            if len(form[0][i][2][0]) > 0:
                form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
            del(form[0][i][2])
    else:
        return dict(form=None)
    if form.accepts(request.vars, session):
        session.flash = T('form accepted')
        #if table == 'ref_fnaregistry':
        #    session.tab_pos=1
        #elif table == 'ref_vregistry':
        #    session.tab_pos=2
        #elif table == 'ref_tregistry':
        #    session.tab_pos=3
    elif form.errors:
        response.flash = T('form has errors')
        #if table == 'ref_fnaregistry':
        #    session.tab_pos=0
        #elif table == 'ref_vregistry':
        #    session.tab_pos=1
        #elif table == 'ref_tregistry':
        #    session.tab_pos=2
        #elif table == 'ref_eregistry':
        #    session.tab_pos=3
    else:
        response.flash = T('please fill out the form')
    return dict(form=form)

Thanks...

Richard





On Mon, Jun 27, 2011 at 7:31 PM, Anthony <[email protected]> wrote:

> On Monday, June 27, 2011 4:36:29 PM UTC-4, Anthony wrote:
>>
>> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote:
>>>
>>> Also, I just tried to change the compileapp.py with Storage... It stop to
>>> send the traceback and I got a : invalid view (ref/create_fvte.load)...
>>
>>
>> Do you have an explicit create_fvte.load view, or are you relying on
>> generic.load? I think generic views aren't being used with LOAD and
>> ajax=False (generic views are also disabled by default unless the request is
>> local).
>>
>
> FYI, I just submitted a patch to fix this problem -- so components with
> ajax=False should be able to make use of generic views again (this broke
> when we introduced response.generic_patterns, which wasn't getting passed to
> non-ajax components).
>
> Anthony
>

Reply via email to