EDIT: It is much easier to implement now in Meteor 0.8.3 :
Template:
<template name="docTitle"> <span class="editable" title="Rename this document" data-autotext="never">{{this}}</span> </template>
the code:
Template.docTitle.rendered = -> tmplInst = this this.autorun -> # Trigger this whenever data source changes Blaze.getCurrentData() # Destroy old editable if it exists tmplInst.$(".editable").editable("destroy").editable display: -> success: (response, newValue) -> # do stuff
To make this the most effective, make sure that the data context of the edited template is just an editable field, as in the example above with {{> docTitle someHelper}} .
Deprecated information for Meteor 0.8.0 to 0.8.2
I also had to do this, but was not sure about using the global assistant in my application. So I tried to accomplish this by simply changing the behavior of the editable.
The main thing that needed to be done, after viewing the documents and the source, were:
Here's the code (apologies for Coffeescript):
Template.foo.rendered = -> container = @$('div.editable') settings =
This is ugly because it destroys and re-creates the popover after setting a new value, so that the form field is updated with the correct value.
After some additional reverse engineering, I found a cleaner way to do this, which does not require the destruction of the editable. Gadi was right because container.data().editableContainer.formOptions.value has something to do with it. This is because this value is set after the update , because x-editable believes that it can cache it now. Well, it cannot, therefore we replace it with the original function, therefore the value continues to be updated from the text field.
Template.tsAdminBatchEditDesc.rendered = -> container = @$('div.editable') grabValue = -> $.trim container.text()
Notes:
I will try to make it more concise in the future, expecting better support from Meteor, depending on the data in response.