[New Feature] Autobinding for Element Plugins

Hello,

We just enabled plugin builders to support autobinding! You can now check the box in the Plugin Editor, and your users will be able to specific which thing should be bound to the element. You can then call

instance.publishAutobinding(value);

when your element wants to publish a new value, while you are able to access the bound value in the update function as properties.autobinding.

12 Likes

@seanhoots can you please enable auto binding for your Air Date/Time Picker?

3 Likes

Really required. We had to use the default date control because of Auto-bind feature.

@daniel3 and @leaseadmin i’ve added auto-binding to the Air Date/Time picker.

@emmanuel
There is a method to check if user has enabled auto-binding ?
This is useful for “initial value” field of an input component.
I can choose [properties.autobinding] value for initial value only if auto-binding is enabled by user otherwise I choose initial value inserted by user.

I’m waiting for a solution. Bye.

@studio.purracchio: I’ve not played with the plugin autobinding option, but the point here is that, if autobinding is enabled and a value has been provided, properties.autobinding will exist and be non-null.

We check for the existence and truthiness of an object like this:

    if (properties.autobinding != null) {
     // properties.autobinding exists, do something
    } else { //do something else cuz .autobinding does not exist}

Or much more succinctly:

var initial-value = properties.autobinding != null ? properties.autobinding : some-other-value

Thank you Keith for your reply,
however You know that if DB value is a text it can be null as well.
In that case, properties.autobinding may not exists or may be a void text field.
…and then…
In my opinion the most elegant solution is to make visible the variable that determines whether the user has activated autobinding.
That variabile exists. Bubble team must only create a reference to it.
For example: properties.is_autobinding :yum:

Someone here has a example of instance.publishAutobinding(value); code?