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

custom data html attributes #42

Closed
tsur opened this issue Jun 4, 2015 · 5 comments
Closed

custom data html attributes #42

tsur opened this issue Jun 4, 2015 · 5 comments

Comments

@tsur
Copy link

tsur commented Jun 4, 2015

Hi! and thank you all for working on this great framework.

I'm trying it out to set a custom data and contenteditable attribute but not sure if i'm doing something wrong. This is not working for me:

h('span', { 'data-type':'somethingHere', 'contenteditable': true }, 'name: ', model.name);

Anyhow, I'll check the source code to check what's going on.

Thank you very much!

@joshski
Copy link
Member

joshski commented Jun 4, 2015

Hi @tsur,

Non-standard HTML attributes should be added to an attributes object, like this:

var plastiq = require("plastiq");
var h = plastiq.html;

function render(model) {
  return h(".editable", { attributes: { contentEditable: true } }, "Edit me");
}

plastiq.append(document.body, render, {});

...however, beware that setting contenteditable to true may not have the effect you're looking for! That is, I don't think plastiq hooks into any contenteditable events to support any kind of updating of the model.

@refractalize
Copy link
Member

Hi @tsur,

For these you want to use contentEditable: true and dataset: {type: 'somethingHere'}.

@joshski turns out contentEditable does seem to work outside of attributes: {}, just been using it now by chance!

virtual-dom uses JavaScript names for things like className and contentEditable but plastiq prefers to stay closer to HTML since that's much more familiar to people. I tend to change them as I bump into them so I'll get these changed (continuing to allow the JavaScript names too of course.)

@msegundo
Copy link

msegundo commented Jun 4, 2015

Thanks!! It works.

@refractalize
Copy link
Member

fixed in 96f9491, and released in v1.17.0

@tsur
Copy link
Author

tsur commented Jun 5, 2015

It worked on the new release, great! thank you!

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