Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search from keypath for event delegates? #250

Closed
kivikakk opened this issue Nov 6, 2013 · 3 comments
Closed

Search from keypath for event delegates? #250

kivikakk opened this issue Nov 6, 2013 · 3 comments

Comments

@kivikakk
Copy link
Contributor

kivikakk commented Nov 6, 2013

Wondering if this is something that would be considered!

That is to say:

{{#xyz}}
  {{thing}}
  <button on-click="stuff">
{{/xyz}}

Assuming xyz is an object, right now that will attempt to resolve the mustache to xyz.thing, and the event delegate will just be stuff. It would be neat if we could check for a delegate xyz.stuff first.

I realise there's not exactly a hierarchy for event delegates as there is a hierarchical model, but it could be super useful. I'd be willing to cook up a patch if this is something you'd consider accepting.

@kivikakk
Copy link
Contributor Author

kivikakk commented Nov 6, 2013

It turns out I basically want #74, and this would be helpful for that purpose.

Presently, I'm defining reusable "extensions" which use a particular keypath prefix for all gets/sets; e.g. for a reusable "description" component, one defines a partial which only uses (at the top level) restricted references, then a function which takes a Ractive instance and a keypath prefix, and attaches all its event delegates/observers/does whatever else it needs to initialise the extension.

It works well enough, except for event delegates in the extension partial.

A hacky workaround is to expose the keypath prefix in the model (ractive.set(keyprefix + "keyprefix", keyprefix);), and then use on-click="{{.keyprefix}}click". I sort of can't believe that works, but it does.

@kivikakk
Copy link
Contributor Author

kivikakk commented Nov 6, 2013

I'm going to try reimplementing what I've done so far with components to see if this is all moot.

@kivikakk
Copy link
Contributor Author

kivikakk commented Nov 6, 2013

Yeah, okay; this "feature" would likely be more harm than good. I reimplemented everything with components, and it's muuuuch cleaner. Events are currently broken (#244, #245), but they're precisely what I want. (using jQuery events as a stop-gap measure.)

Closing~

@kivikakk kivikakk closed this as completed Nov 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant