How to open composer with prefilled content?


(Eero Heikkinen) #1

I figured out I can open the composer from within a route with

this.controllerFor('composer').open({
  action: Discourse.Composer.CREATE_TOPIC,
  categoryId: whatever_category_id,
  draftKey: "new_topic"
});

How could I tell composer to initially fill the new topic with my desired content, instead of being blank?

I’m adding a route for creating events by clicking on a calendar, so I already know the date and some other information which I would like to display in the body to help the user.


Easier way to send a PM to a group?
[Solved] In plugin: opening the composer without changing the route
Private messages to a group, or other means to handle private support requests
(Robin Ward) #2

I don’t think there’s an easy way to do this right now but our quote button does something similar.


(Eero Heikkinen) #3

It’s not super clean, but this seems to work:

var composer = this.controllerFor('composer');
composer.open({
  action: Discourse.Composer.CREATE_TOPIC,
  categoryId: whatever_category_id,
  draftKey: "new_topic"
}).then(function() {
  composer.appendText('New event weee');
});

(Руслан Корнев) #4

This feature has been made here. :boom:


(Sam Saffron) #5