[Seaside] Re: Generating an callback URL for third-party use
Bob Arning
arning315 at comcast.net
Wed May 28 01:08:10 UTC 2014
Well, as for using a single callback to cover lots of click targets, I
use something like this
--- a single onClick: for the table---
html table
onClick: (
html jQuery ajax
callback: [ :value |
selIndex _ myNums findFirst: [ :each | each asString =
value].
]
value: ((html jQuery: '.',id1) filter:
'return(bobclicktest(this))' asFunction) first html;
...
--- each cell in table that you want to be clickable has the class id1 ---
html tableRow: [
myNums do: [ :e |
html tableData
class: id1;
...
--- and bobclicktest checks if the event occurred in a particular element---
function bobclicktest(target) {
return(
($(target).offset().top < window.event.pageY)
&& ($(target).offset().top + $(target).height() >
window.event.pageY)
&& ($(target).offset().left < window.event.pageX)
&& ($(target).offset().left + $(target).width() >
window.event.pageX)
)
}
On 5/27/14 8:25 PM, Esteban A. Maringolo wrote:
> Additionally to this, is it possible to pass an argument to such callback?
>
> I'm dealing with a data table on the browser and want to show details
> of the selected item once clicked. Instead of creating hundreds of
> callbacks (one per row), I'd like to pass an identifier of such item
> to the callback, in order to be able to retrieve it from the
> datasource. Is it possible?
>
> Is there a better way to register a callback that does exactly the same?
>
> something to replace this:
> collection do: [:each | html anchor callback: [self edit: each]; with: 'Edit' ]
>
> Into a reutilizable callback with an added parameter.
>
> I looked into the WAListTag class and it seems there is no other way
> other than creating a single callback per item.
> Maybe it is cheap in terms of memory and I worrying about an non
> existing problem. But there should be other way.
>
> Regards!
>
> Esteban A. Maringolo
>
>
> 2014-05-27 19:46 GMT-03:00 Esteban A. Maringolo <emaringolo at gmail.com>:
>> I'm struggling to find a clean way of generating an url to be used for
>> external reference from a javascript library/plugin, such as
>> crossfilter or DataTables.
>>
>> E.g the constructor configuration object has a dataUrl parameter,
>> which will be used by the plugin to retrieve the data.
>>
>> $('element').plugin({dataUrl: "..."});
>>
>> I can generate the expression to retrieve it from anywhere, but what I
>> want is to associate an url with a callback that will answer the data
>> requested.
>>
>> Today I'm assigning results to a local variable using a predefined
>> callback function, and then initializing my data dependent function
>> assuming there is going to be data in that variable.
>>
>> Ej:
>> html document addLoadScript: (
>> ((html jQuery getJson
>> json: [ :json | self renderItemsOnJson: json ];
>> onSuccess: (JSStream on: 'myCallbackFunction(arguments[0]);')
>> asFunction) asFunction assignTo: 'loadCrossfilterData')).
>>
>> html document addLoadScript: (JSStream on: 'loadCrossfilterData()').
>>
>> I want some way to create a url callback in the way of:
>>
>> callbackUrl := html magicalCallbackRegister: [ :json | self
>> renderItemsOnJson: json ]. "answers a url"
>>
>> JSStream on: '$(''#element'').plugin({dataUrl:"', callbackUrl, '"})'.
>>
>> which once rendered as JS would be:
>>
>> $('#element').plugin({dataUrl:"/app/_s=...&_k=...&n"});
>>
>> I know this must be possible, because Seaside does it for all the
>> callbacks, but I don't know how to create a simple callback and then
>> get it's url to pass it around.
>>
>> I hope all I wrote is intelligible. Otherwise I can rephrase it in
>> other unintelligible way. :)
>>
>> Esteban A. Maringolo
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20140527/4c8e4b92/attachment-0001.htm
More information about the seaside
mailing list