given that you are using jquery templates to iterate over your items
and not knockout templates (i.e. using a foreach in the template
binding), how is knockout supposed to determine which object you mean
to pass into the click handler? There are at least 4 variables that
could make sense to be used in that binding: $item, $data,
contactGroup, and contact. Even the top level viewModel object would
make sense depending on the programmers intent.
>
> Now, a few questions:
>
> * Does the change I made have any implications that would cause
> problems? I don't know much, at the moment, about the internals, but
> maybe you can tell by quickly just by looking at it.
> * Would it be possible to get a change like this into Knockout? I
> don't know anything about future plans...
>
> I am still going to look over your answers, but for now, I am going to
> stick with my change (though I hate forking things unless absolutely
> necessary) since it works the way I feel it should have. Of course, I
> honestly only started using this library in the last couple of days,
> so I reserve the right to change my mind! :)
>
> Jason
>
>
> On Jun 22, 3:01 pm, rpn <rnieme...@gmail.com> wrote:
>> Using an anonymous function is the recommended and really the only way for
>> passing parameters to a function out of the box, as the function is only
>> passed the event. This is generally the way that it is described in
>> documentation, etc.
>>
>> This got a little bit long, but I wanted to fully explain some of the
>> options. Here is a jsFiddle of these options:http://jsfiddle.net/rniemeyer/BATnz/
>
> <snip/>
--
-barkmadley
sent from an internet enabled device
From what I understand of the code base, the only thing requiring
knockout to use jquery (all the jquery specific code is protected by
checks for its existence) is the template binding which you don't have
to use (I also believe someone attempted to get knockout working with
mustache earlier in the year).
define a function that takes an id, and returns a function that is
evaluated when the event happens:
https://github.com/barkmadley/barkmadley.github.com/blob/master/things/contacts.html#L214
to use it as the click handler see here (it gets renamed by the
template binding as a template option so don't worry about the names
not matching):
https://github.com/barkmadley/barkmadley.github.com/blob/master/things/contacts.html#L7
This is a little bit less weighty than a custom binding, but is less reusable.