Meteor-Editable: X-Editable inspired inline editor for Meteor

1,250 views
Skip to first unread message

Dave Workman

unread,
Apr 28, 2014, 4:17:09 PM4/28/14
to meteo...@googlegroups.com
Hey guys,

I've just released the first version what I call Meteor-Editable. It's a copy-cat of X-Editable but you use Blaze component syntax to initialize it and everything else just works. It doesn't do everything x-editable does, but I hope to get there eventually, for now if there's something missing that you really need, let me know and I'll try to work it in. Here's the demo/documentation site:

salicon....@gmail.com

unread,
Apr 29, 2014, 2:48:42 PM4/29/14
to meteo...@googlegroups.com
Hey there!

I don't see any explanations in the docs on how to populate a select, for example.

Dave Workman

unread,
Apr 29, 2014, 2:53:57 PM4/29/14
to meteo...@googlegroups.com
You are right, I'll add that next update.

One of the options is source, it expects an array of objects formed like so: [{value: 1, text: "text1"}, {value: 2, text: "text2"}, ...]

Dmitriy Shatalov

unread,
Apr 30, 2014, 6:09:26 AM4/30/14
to meteo...@googlegroups.com
Hello.

Can you add inline editable mode?

Dave Workman

unread,
Apr 30, 2014, 1:02:45 PM4/30/14
to meteo...@googlegroups.com
Already working on it! :)
Message has been deleted

Brent Abrahams

unread,
May 6, 2014, 12:49:07 PM5/6/14
to meteo...@googlegroups.com
This is cool, Dave.  Keep up the good work.  I've always felt like Meteor was missing a good native in-line editing package.

neurofuzzy

unread,
May 6, 2014, 2:42:58 PM5/6/14
to meteo...@googlegroups.com
This looks very useful. I am currently using x-editable, but it lacks reactivity and is a little harder to integrate with Blaze. I'll be keeping an eye on this!

Josh Bechard

unread,
May 19, 2014, 4:32:24 PM5/19/14
to meteo...@googlegroups.com
Dave, can you update the example code area with the whole line of code for a select type editable field? I still get a blank box when I use {{> m_editable type="select" source='{{values}}' }} . The helper looks like this Template.donateWith.helpers({
    values: function () {
      var currentValues = [{value: 1, text: "text1"}, {value: 2, text: "text2"}];
      return currentValues;
    }
  });

Dave Workman

unread,
May 19, 2014, 5:18:37 PM5/19/14
to meteo...@googlegroups.com

Just change source='{{values}}' to source=values

--
You received this message because you are subscribed to a topic in the Google Groups "meteor-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meteor-talk/N_bBpOyeKEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joshua Bechard

unread,
May 19, 2014, 9:40:46 PM5/19/14
to meteo...@googlegroups.com
Awesome. Thanks. How do you set one of the values as 'selected'? Or really, how do you add any of the options values to these fields? 
--
Joshua Bechard
Technology Director
1555 NW Gage Blvd.
Topeka, KS 66618
863-738-6901 (mobile)
785-246-6845 (office)

Dave Workman

unread,
May 20, 2014, 9:35:58 AM5/20/14
to meteo...@googlegroups.com
it automatically selects based on where the value in the options list equals the value that's attached to the data object. For instance if you passed this as a config to m_editable:

Session.setDefault('value', 2);

Template.templ.editableConfig = function () {
  return {
    values: [{value: 1, text: "text1"}, {value: 2, text: "text2"}],
    value: Session.get('value')
  };
}

this will render with "text2" as the selected text. If you do a Session.set('value', 1); then it will automatically change the selected value to 1 and display "text1".

Joshua Bechard

unread,
May 20, 2014, 10:20:50 AM5/20/14
to meteo...@googlegroups.com
Ok. I don't understand what is happening here. 

Should I keep my existing template helper? Should this code replace that helper? Should it read like this Template.myTemplateName.editableConfig? If this is the case then do I need to add something to the html portion to let the system know that I need to pass options to m_editable? 

Dave Workman

unread,
May 20, 2014, 10:38:53 AM5/20/14
to meteo...@googlegroups.com
If you look at the bottom of this page under the heading examples: http://meteor-editable.meteor.com/docs you'll see there's really two ways of passing options to Blaze templates. You can make a helper that returns an object, or you can build the option:value pairs directly in the template caller. For example this:

<template name="tmpl1">
   {{> my_templ foo='op1' bar='op2' }}
</template>

is equivalent to:

<template name="tmpl1">
   {{> my_templ options }}
</template>

Template.tmpl1.helpers({
  'options': function () {
    return {
      foo: 'opt1',
      bar: 'op2'
    };
  }
});

So it's really up to you. Depending on what your data context is it might change which option you decide to use. For instance, if you have the value you want to use in the data context it might make sense to just pass it in {{> m_editable value=myVal }}, but if you need to grab it from a session variable, it might make more sense to pass it in through a helper: return { value: Session.get('value') };

Hope that helps,
-Dave

Joshua Bechard

unread,
May 20, 2014, 10:51:19 AM5/20/14
to meteo...@googlegroups.com
Ok, I see, thanks, that answered my question. 

On a separate topic, I have three calls to m_editable and when I click any of the three the box pops up over the first one instead of the one that is clicked. 

In the screenshot I clicked on the word "Check"

Inline image 1 

Dave Workman

unread,
May 20, 2014, 11:20:57 AM5/20/14
to meteo...@googlegroups.com
Thanks for bringing this to my attention. I've released a fix, please tell me if it help. (Run a 'mrt update' to get the new release)

Joshua Bechard

unread,
May 20, 2014, 11:24:17 AM5/20/14
to meteo...@googlegroups.com
Thanks, yes that did fix it. 

James Bower

unread,
Jun 25, 2014, 2:41:16 PM6/25/14
to meteo...@googlegroups.com
Do you have a way to allow/disallow edits for everything on a page?

Jim

Dave Workman

unread,
Jun 25, 2014, 2:57:04 PM6/25/14
to meteo...@googlegroups.com
Yes, sorry the documentation is a little of out date. If you pass in a true value for the option "disabled" it will not go into edit mode, and by default the text will be in a span instead of an a tag. You could use a session variable for each editable to have it set for everything on a page. Example: https://gist.github.com/davidworkman9/dd473d9976899b67f1a1

James Bower

unread,
Jun 26, 2014, 8:37:19 AM6/26/14
to meteo...@googlegroups.com
Thanks for the quick reply.

Jim


--
You received this message because you are subscribed to a topic in the Google Groups "meteor-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meteor-talk/N_bBpOyeKEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jim Bower
Looking for spurs

LinkedIn
Reply all
Reply to author
Forward
0 new messages