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 
callback. You need two actions. One renders the page and one deals with the 
callback events.

For example:

db.define_table('friend',Field('name'))

def manage(): # renders page
    form = SQLFORM(db.friend)
    friends = db(db.friend).select()
    return dict(form=form,friends=friends)

def delete_friend(): # executes callback
    # should check permissions but ok for now...
    del db.friend[request.port_vars.id]
    return 'done'

% views/default/manage.html

{{extend 'layout.html'}}
{{=form}}
<table>
{{for friend in friends:}}
  <tr>
    <td>{{=friend.name}}</td>
    
<td>{{=A('delete',callback=URL('delete_friend',vars=dict(id=friend.id),delete='tr'))}}</td>
  </tr>
{{pass}}
</table>

On Tuesday, 18 December 2012 11:15:15 UTC-6, Daniele wrote:
>
> 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....@gmail.com<javascript:>
> > wrote:
>
>> 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:
>>> <div id="deltutor">{{=A('Delete Role',_class="btn 
>>> btn-danger",_id='deltutorlink'**, callback=URL('edit_profile'),**
>>> delete='#deltutor')}</div>
>>>
>>> in my controller, under the edit_profile method, I have:
>>>
>>> if request.vars.deltutorlink:
>>>         response.flash = T('deltutorlink reached!')
>>>
>>> but this response.flash is never reached. I can't figure out why
>>>
>>>
>>> On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote:
>>>>
>>>> <div id="row123">.... {{=A('delete 
>>>> 123',callback=URL('delete',**args=123),delete='#row123')}} 
>>>> ... </div>
>>>>
>>>>
>>>> The delete argument indicates that upon success you want to remove the 
>>>> <div id="row123">...</div> from the page. If there is a "delete" argument 
>>>> the confirmation popup is automatic. ;-)
>>>>
>>>> On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote:
>>>>>
>>>>> 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 way too long....
>>>>>
>>>>> On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote:
>>>>>>
>>>>>> 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 wrote:
>>>>>>>
>>>>>>> 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 when I click the button, nothing happens. Why is this??
>>>>>>>
>>>>>>> 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 
>>>>>>>> display that button??
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 



Reply via email to