Nice one, glad you got that sorted out.
Regards
Steve
On Dec 14, 4:49 pm, Ω Alisson <
thelinuxl...@gmail.com> wrote:
> I've achieved what I need with this:
>
> <div id="accordion" data-bind="jqAccordion:{},template: {name:
> 'eventoTemplate',foreach: events,afterAdd:
> function(elem){$(elem).trigger('valueChanged');}}"></div>
>
> ko.bindingHandlers.jqAccordion = {
> init: function(element, valueAccessor) {
> var options = valueAccessor();
> $(element).accordion(options);
> $(element).bind("valueChanged",function(){
> ko.bindingHandlers.jqAccordion.update(element,valueAccessor);
> });
> },
> update: function(element,valueAccessor) {
> var options = valueAccessor();
> $(element).accordion('destroy').accordion(options);
> }
>
> };
>
> Not so clean, but it works :)
>
> 2010/12/14 Ω Alisson <
thelinuxl...@gmail.com>
>
>
>
>
>
>
>
> > The value represents the options When I call jqAccordion: {} inside a div,
> > it initializes correctly, the problem is that the update function is not
> > invoked when the div receives template data, so the accordion doesn't
> > display correctly(it needs to be recreated).
>
> > 2010/12/14 Steven Sanderson <
ste...@stevensanderson.com>
>
> > > it doesn't trigger the update when data is added to the accordion
> >> div(with template)
>
> > Sorry, I don't really follow what you're trying to do. Is the value passed
> >> to your binding supposed to represent options for initialising the according
> >> (it looks that way from your code), or is it supposed to represent some data
> >> shown inside the accordion (as your question suggests, even though there's
> >> nothing of that sort in the code)?
>
> >> It looks like you're using the binding value to represent initialisation
> >> options, and so it should correctly invoke the "update" handler whenever
> >> those options change, assuming the options are an observable. Is that really
> >> what you're trying to do?
>
> >> Steve
>
> >> 2010/12/14 Ω Alisson <
thelinuxl...@gmail.com>