Re: [web2py] Re: Add button to form & access from view

2012-12-18 Thread Massimo Di Pierro
There are some design issues here. The main think is that you click on the button you want something to happen without the reloading the page. Yet you make the callback=URL() point to the same action that generates the page while it should point to a separate action which just performs the

[web2py] Re: Add button to form & access from view

2012-12-18 Thread Daniele
I tried doing this but absolutely nothing happens when I click the button On Tuesday, December 18, 2012 5:10:01 PM UTC, Massimo Di Pierro wrote: > > BTW... > > def edit_record(): > ... > if request.vars.deltutorlink: > response.flash = T('deltutorlink reached!') > ... > > If ed

Re: [web2py] Re: Add button to form & access from view

2012-12-18 Thread Daniele Pestilli
Sure thing Massimo, here's my view: http://bpaste.net/show/nSrzmYsurH2CnXLrpdwJ/ here's my controller: http://bpaste.net/show/KEx38v6ARYgsUwG8oXMd/ Daniele On Tue, Dec 18, 2012 at 5:07 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > Please post your code so we can try it. > > Are

[web2py] Re: Add button to form & access from view

2012-12-18 Thread Massimo Di Pierro
BTW... def edit_record(): ... if request.vars.deltutorlink: response.flash = T('deltutorlink reached!') ... If edit_record is called via ajax and not within a component, than response.flash is not displayed because there is no view associated to the callback. You can do: de

[web2py] Re: Add button to form & access from view

2012-12-18 Thread Massimo Di Pierro
Please post your code so we can try it. Are you sure the edit_profile is not being called? Can you use the JS console in chorme to see what is going on? Massimo On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote: > > Still isn't working for me :'( > > In my view, I have: > {{=A('Delete

[web2py] Re: Add button to form & access from view

2012-12-18 Thread Daniele
Still isn't working for me :'( In my view, I have: {{=A('Delete Role',_class="btn btn-danger",_id='deltutorlink', callback=URL('edit_profile'),delete='#deltutor')} in my controller, under the edit_profile method, I have: if request.vars.deltutorlink: response.flash = T('deltutorlink re

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Massimo Di Pierro
{{=A('delete 123',callback=URL('delete',args=123),delete='#row123')}} ... The delete argument indicates that upon success you want to remove the ... from the page. If there is a "delete" argument the confirmation popup is automatic. ;-) On Saturday, 15 December 2012 11:35:28 UTC-6, Danie

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Daniele
I want to do something very simple but it's taking me eons to do this~ When the button is clicked, I want a javascript alert to pop up that asks, are you sure? Yes/No. If Yes, then run this code: auth.del_membership('role') No redirection, just delete the role. That's all -_- this is taking me w

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Massimo Di Pierro
None. You are asking to ":eval" the result. It meas the action is supposed to return JS def test(): return "alert('hello')" anyway, you should debug this with the JS console in chrome. We do not know exactly how your code looks like. On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wr

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Daniele
I am trying with: {{=A('Delete Role', _class="btn btn-danger", _id="del_role_tutor", callback=URL('test'), target=":eval")}} and in my controller: def test(): return "Hello" or def test(): return dict() but nothing happens. Why is this?? On Monday, December 10, 2012 9:15:30 PM UTC,

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Daniele
Please pardon my ignorance, I didn't know there was a button helper. And thanks Massimo, I'll give the A with the class btn a try now! On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: > > When I use form.add_button() I am able to add a button to a form, which I > can display with {{=f

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Massimo Di Pierro
As NIphlod says there is a BUTTON helper. Yet instead of Delete Role I would do: {{=A('Delete Role', _id="b_normal", _class="btn btn-danger", callback=URL('test'), target=':eval')}} which will look the same. Why use BUTTON when you can use A with class "btn" and works the same? On S

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Niphlod
Don't take it in the wrong way, I'll start with a little introduction: web2py is a framework that can do a lot of stuff. When it generates an HTML page the way you told him so, it returns it to the browser. From then on, it's just how HTML works: any button (without javascript intercepting the

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Daniele
I tried putting this HTML Delete Role which I saw on a stackoverflow post. However, even when I do that and click the button, the form ALWAYS gets submitted. I already have a submit button so I don't understand why the form is being submitted via other buttons as well. Does anyone know why this

[web2py] Re: Add button to form & access from view

2012-12-15 Thread Daniele
It's quite pathetic that web2py doesn't provide a BUTTON helper by the way... On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: > > When I use form.add_button() I am able to add a button to a form, which I > can display with {{=form}} in my view. > > However, if I'm making a custom for

[web2py] Re: Add button to form & access from view

2012-12-14 Thread Daniele
So it's not possible to do this with a button? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: > > When I use form.add_button() I am able to add a button to a form, which I > can display with {{=form}} in my view. > > However, if I'm making a custom form using form.custom, how can I d

[web2py] Re: Add button to form & access from view

2012-12-14 Thread Niphlod
onclick accepts a bit of javascript, not an url On Friday, December 14, 2012 1:16:22 PM UTC+1, Daniele wrote: > > I'm also trying this but it doesn't work: > > Delete Role > > Another thing I noticed is that whatever I put in onclick, it keeps trying > to submit the form. I don't want to subm

[web2py] Re: Add button to form & access from view

2012-12-14 Thread Daniele
I'm also trying this but it doesn't work: Delete Role On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: > > When I use form.add_button() I am able to add a button to a form, which I > can display with {{=form}} in my view. > > However, if I'm making a custom form using form.custom, h

[web2py] Re: Add button to form & access from view

2012-12-14 Thread Daniele
I have the button http://127.0.0.1:8000/examples/global/vars/URL>(del_role)}}" class="btn btn-danger">Delete Role And in my controller I try to put def del_role and, if the user has membership, i want to del_membership for that role. But this doesn't seem to be working. You were telling me t

[web2py] Re: Add button to form & access from view

2012-12-11 Thread Massimo Di Pierro
{{=A('click me',_href=URL('action'))}} (redirects) or {{=A('click me', callback=URL('action'))}} (call via ajax) or {{=A('click me', callback=URL('action'),target="t")}} (call via ajax and store result in t) or {{=A('click me', callback=URL('action'),delete="div#c")}} (call via ajax and d

[web2py] Re: Add button to form & access from view

2012-12-11 Thread Daniele
Ok. What's the correct way of associating an action to the HTML button with web2py? On Tuesday, December 11, 2012 12:30:34 AM UTC, Massimo Di Pierro wrote: > > This is not worth it. If you make a custom form than you are using html, > you may as well make the button in html. > > On Monday, 10 De

[web2py] Re: Add button to form & access from view

2012-12-10 Thread Massimo Di Pierro
This is not worth it. If you make a custom form than you are using html, you may as well make the button in html. On Monday, 10 December 2012 15:15:30 UTC-6, Daniele wrote: > > When I use form.add_button() I am able to add a button to a form, which I > can display with {{=form}} in my view. > >