Thanks.
An excellent explanation and much appreciated.
That works.

I'll look at extending this to a new page and/ or a modal window.

On Wednesday, 18 April 2012 08:53:50 UTC+10, Niphlod wrote:
>
> sorry to be so late ....
>
> if you have {{=URL('tree','stree','index')}} anywhere in the view it gets 
> translated to:
>
> /appname/tree/stree/index
>
> Now, if you check your source, you should see it.
> So, try to "hardcode" that url without using {{=URL()}} syntax and check 
> if your javascript is working.
>
> Actually, it won't :P. No fault from web2py side, but from the javascript 
> one....
>
>  bind("select_node.jstree", function (event, data) { "xxx" } is a function 
> where you have to "decode" data to something useful....
> as you said, data.rslt.obj.attr("id") contains the id value of the 
> selected item.
> If you want to pass that to /appname/tree/stree/index, you need to 
> "append" that to the url.....
> Prepare the index() function as :
>
> def index():
>       record_id = request.args(0)
>       .......
>       return dict(form=form) 
>  
> so the form returns the form for the correct record if called as 
> /appname/tree/stree/index/the_actual_selected_id
>
> Then, you must "prepare" a div into the page where you want the form to be 
> loaded, as 
>
> <div id="theformdiv"></div>
>
> This is merely a placeholder, you can put it where you want, as long as it 
> is in the same page where the tree is loaded, and where you can then put 
> the following javascript snippet
>
>
> bind("select_node.jstree", function (event, data) {     
>     var baseurl = "{{=URL('tree', 'stree', 'index', extension='load')}}" + 
> "/" + data.rslt.obj.attr("id");
>     web2py_component(baseurl, 'theformdiv');
>   } 
>
> the "web2py_component" part calls the 
> /appname/tree/stree/index/theselectedid with ajax and place the obtained 
> result into the div with id = #theformdiv
>
> Il giorno mercoledì 18 aprile 2012 00:27:51 UTC+2, Simon Ashley ha scritto:
>>
>> Thanks but unfortunately this doesn't help as the controller needs to be 
>> called from within the view.
>>
>> (what we believe to be normal python escaping techniques i.e. {{ ... }} 
>> doesn't seems to be returning appropriate responses.
>> Have been stuck on this for weeks now. 
>> While our javascript skills may be basic, would have thought we would 
>> have come across example code by now)
>>
>> On Wednesday, 18 April 2012 00:18:25 UTC+10, villas wrote:
>>>
>>> From the book:
>>>
>>> response.render(view, vars): a method used to call the view explicitly 
>>> inside
>>> the controller. view is an optional parameter which is the name of the 
>>> view
>>> file, vars is a dictionary of named values passed to the view.
>>>
>>> HTH David
>>>
>>

Reply via email to