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

Use a ReactiveVar instead of a Collection #71

Open
echo66 opened this issue Apr 28, 2016 · 6 comments
Open

Use a ReactiveVar instead of a Collection #71

echo66 opened this issue Apr 28, 2016 · 6 comments

Comments

@echo66
Copy link

echo66 commented Apr 28, 2016

Greetings!

I have the following HTML template:

<template name="type_create">

        <form>
            <p class="editable-text-trigger">
                <strong>Title: </strong>
                {{> editableText context=data field="title" textarea=false removeEmpty=false wysiwyg=false allowEmpty=false}}
            </p>
            <p class="editable-text-trigger">
                <strong>Description: </strong>
                {{> editableText context=data field="description" textarea=true removeEmpty=false wysiwyg=true allowEmpty=false}}
            </p>
            <p>
                <button type="submit">Create Type</button>
            </p>
        </form>

</template>

and no JS file.

I initialize the template view in the following way:

var view = Blaze.renderWithData(Template['type_create'], 
                                function() { return new ReactiveVar({ title: "aa", description: "bb" }); }, modal.body[0]);

When I try to update one of the text inputs, I see the following error in the console:

Exception while simulating the effect of invoking '_editableTextWrite' errorClass {message: "Match error: Expected string, got undefined", path: "", sanitizedError: errorClass, errorType: "Match.Error"}errorType: "Match.Error"message: "Match error: Expected string, got undefined"path: ""sanitizedError: errorClassstack: (...)get stack: get stack()set stack: set stack()__proto__: Error Error: Match error: Expected string, got undefined

debug.js:43
@JackAdams
Copy link
Owner

This package is just for updating fields from documents in collections.

@echo66
Copy link
Author

echo66 commented May 4, 2016

Do you know what can be changed in order to use reactive variables?

@JackAdams
Copy link
Owner

JackAdams commented May 7, 2016

You could overwrite the EditableText.update function on the client and make some tweaks to the editable-text.html and editable-text.js files to add new possible parameters when initializing the widget (so it knows which ReactiveVar to target) but, at that stage, it might just be easier to write a dedicated package to deal with ReactiveVar's. Otherwise you end up with a big bunch of code on client and server that never gets used by your app.

@dpatte
Copy link

dpatte commented Jun 16, 2016

I just noticed this, after posting a similar request (you can delete the other request, if you wish).

I was also wondering, what about local collections? Perhaps I could have a single record in a local collection with the fields I want to edit locally? Does that work?

@JackAdams
Copy link
Owner

I'm pretty sure this wouldn't work with local collections without overwriting the EditableText.update function on the client (in which case you wouldn't be able to make fields of documents in your db collections editable anymore). In theory, the package could be extended to include this functionality, but it's unlikely I'll get time to do this anytime soon.

@t3db0t
Copy link

t3db0t commented Aug 18, 2016

Hm, I'm also suddenly finding a need for this, so that I can reactively change the size of the text depending on its length—unless there's a callback for when the value changes?

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