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

Bindable without jQuery #2

Open
mkitt opened this issue May 4, 2013 · 10 comments
Open

Bindable without jQuery #2

mkitt opened this issue May 4, 2013 · 10 comments

Comments

@mkitt
Copy link
Member

mkitt commented May 4, 2013

We talked briefly about this yesterday, but it would be super handy to have a version of bindable that works without jQuery using only native JavaScript. The challenge here is storing the registry, which @gvarela has more insight on. Not a high priority, but would be really handy for those projects that only require a little bit of JavaScript and doesn't necessarily need jQuery involved.

@jedschneider
Copy link
Member

it would also complicate how we expect to be able to handle @el within the constructor. we probably have a lot of code right now that depends on that acting like a jquery object

Jed Schneider

"I invented the term 'Object-Oriented', and I can tell you I did not have C++ in mind."

  • Alan Kay

On Saturday, May 4, 2013 at 5:08 PM, Matthew Kitt wrote:

We talked briefly about this yesterday, but it would be super handy to have a version of bindable that works without jQuery using only native JavaScript. The challenge here is storing the registry, which @gvarela (https://github.com/gvarela) has more insight on. Not a high priority, but would be really handy for those projects that only require a little bit of JavaScript and doesn't necessarily need jQuery involved.


Reply to this email directly or view it on GitHub (#2).

@mkitt
Copy link
Member Author

mkitt commented May 4, 2013

Yep, that's why I think there are two separate files. One with jQuery and one without. It's a decision that's made at the start of a project on which one we are using.

@jayzes
Copy link
Member

jayzes commented May 5, 2013

Theoretically, we could detect the presence of $ and wrap the element if it's present, otherwise don't.

mkitt added a commit that referenced this issue May 9, 2013
Lots of potential issues here, but getting the ball rolling.

See #2 for the conversation
@mkitt
Copy link
Member Author

mkitt commented May 9, 2013

Okay took an initial stab at this thing including the storage of the instance back on the element.

I'll need to test this with a few browsers first, but I imagine there are some problems with storing the instance back on the @el, mainly with IE. IE (even 10 🐼) doesn't support the dataset property which is where data- attributes typically reside. There is a good article on HTML5 Doctor about the dataset property. I'll test this out some on various browsers and see about alternatives when the dataset property doesn't exist.

@gvarela, I'll defer to you on the instance storage within the @el, since this is your baby.

Also, need to do some trickery around the naming of the instanceKey for this to work right. The regex is pretty basic and probably needs to be tuned a bit.

I wrote it in plain old JavaScript. If we are going to distribute this thing as from the discussion in #1, it's probably a better idea for the distributed source to be native and not just the output from CoffeeScript. Lots of haters out there who'll reject it based on just that notion. Stupid yes. I do think we should have the CoffeeScript examples either right next to them, or in another branch, but I'm cool either way.

@gvarela
Copy link
Member

gvarela commented May 9, 2013

The instance storage is to prevent accidental double binding as well as make it easy to access the instance should you need a reference to manipulate it in some way. As long as the way you implemented it handles those scenarios I would call it good.

@mkitt
Copy link
Member Author

mkitt commented May 9, 2013

Yeah it's just...

if (!el[this.instanceKey]) {
  el[this.instanceKey] = new _class(el)
}

@gvarela
Copy link
Member

gvarela commented May 9, 2013

Yeah saw that. Since I don't know the modern way to do that I just wanted communicate the intent.

@jedschneider
Copy link
Member

I kinda feel like we shouldn't be apologetic about releasing it as coffeescript. I had a chat with a friend of mine that is really into node development and he said the same thing, he stopped writing coffeescript because he couldn't get other node developers to work with him on it. I think that is a really sad reflection of that community. I think we should be more like

> 'our core use case is coffeescript, and that fits into the rails pipeline well but if you want to use it as a vendored library to augment how you write javascript, thats great, heres a file you can use.'  

I dont know, is that too hardline?

Jed Schneider

"I invented the term 'Object-Oriented', and I can tell you I did not have C++ in mind."

  • Alan Kay

On Thursday, May 9, 2013 at 11:59 AM, Gabe Varela wrote:

Yeah saw that. Since I don't know the modern way to do that I just wanted communicate the intent.


Reply to this email directly or view it on GitHub (#2 (comment)).

@gvarela
Copy link
Member

gvarela commented May 9, 2013

I think for a library this small it should be js. There isn't really an advantage when there is this little code.

@jedschneider
Copy link
Member

so, @mkitt I think we are good to close this issue, right?

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

4 participants