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

Dynamically assign ui in JSON stored manifest? #15

Closed
tmikaeld opened this issue Oct 15, 2015 · 7 comments
Closed

Dynamically assign ui in JSON stored manifest? #15

tmikaeld opened this issue Oct 15, 2015 · 7 comments

Comments

@tmikaeld
Copy link

I've been trying to solve this, but I'm all out of ideas.

I'm trying to dynamically assign selectors for the form since these are rendered by the server.

    "ui":{
        "#Text1": { bind: "Text1" },
        "#Setting6": { bind: "Setting6" },
        "#Setting7": { bind: "Setting7" }
    }

So this is the target selectors, but i cannot use code here afaik to get the attribute data from the selector dynamically.

The selector where get the data from looks like this:

<div class="editable header" data-fieldname="Text1" data-fieldtype="header" data-setting2="Setting7" data-setting1="Setting6"></div>

The only "solution" i've come up with is to extend manifest after the JSON have been loaded form store, but that ruins the portability of the manifest.

manifest.ui = { }
manifest.ui["#"+$('.editable.header').data('fieldname')] = {bind: $('.editable.header').data('fieldname')}
manifest.ui["#"+$('.editable.header').data("setting1")] = {bind: $('.editable.header').data("setting1")}
manifest.ui["#"+$('.editable.header').data("setting2")] = {bind: $('.editable.header').data("setting2")}

Any other ways to retrieve it dynamically directly in the manifest?

@ermouth
Copy link
Owner

ermouth commented Oct 15, 2015

You can‘t use HTML data attributes as both DOM selectors and data pointers. Although you can try to generate manifest on the fly after page load.

Init function can take your div, parse it and dynamically generate child manifest, that will then be bound as a child form.

To notice, your approach looks extremely cryptic.

@tmikaeld
Copy link
Author

Ah, child form - that solves it completely!

I'm basically using jQuery.my to edit page content, maybe that is why it looks cryptic?

@tmikaeld
Copy link
Author

By the way, does a child form take a performance hit?
Compared to cloudwall.me manifest, mine are tiny so shouldn't be a problem in any case.

@ermouth
Copy link
Owner

ermouth commented Oct 15, 2015

does a child form take a performance hit

Child forms are highly optimized, so it‘s insignificant, nearly zero.

BTW, there‘s a proof of concept, what can be done using $.my for extreme content editing, see http://inliner.cloudwall.me/ddlab/_inliner#144184061501ff0vgzjf. Hope it can help in some way.

@ermouth
Copy link
Owner

ermouth commented Oct 15, 2015

Oh, to add. You can set params:{strict:true} for child manifest you generate using init, to skip unjson traverser. It can give you millisecond or two during child form initialization.

@tmikaeld
Copy link
Author

Really nice inline editor! I like the idea.

What i initially started with is blocks of custom server-rendered content, each block have a content editing form that uses jQuery.my for the live-editing and loading from JSON database. Works great!

But some blocks have really bad performance especially on re-rendering from the server, so the new approach is to edit only smaller parts (like in this case the header) upon clicking on it. This solved the performance and re-rendering-time issue.

Thanks for the tip, will do some tests with this and see how it works.

By the way, i see no way to donate to jQuery.my's development?

@ermouth ermouth closed this as completed Oct 15, 2015
@tmikaeld
Copy link
Author

Thanks for the offert to help with specific issues, i will get back to you on that if i get into issues.

I don't really like to bother maintainers with these questions, but when it's such a specific system there really is no other place to ask.

I understand what you mean with donating to OSS projects, i often check if the project have a company backing it and if they do - i donate the spare money to the smaller ones without company backing first.

When/if i can afford to hire a full-time developer to work on this "app" I'm making, then I'll contribute to the development of jQuery.my by submitting potential new features, fixes, code. I think that's the best way to give back to any OSS project, to contribute to it's development.

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

2 participants