Replacement for View class (in old directory views) in js

The directory views doesn’t exist in discourse 1.8 so i don’t find the class TopicView…

There is an example of an old code and i want to replace it :
import TopicView from "discourse/views/topic";

TopicView.reopen({

      didInsertElement: function () {
        this._super();
        Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
      },
      afterRenderEvent: function () {
        var is_wordpress = this.get('topic').is_wordpress;
        var creator = this.get('posters.firstObject');
        if (is_wordpress) {
          this.$().addClass("topic_wordpress");
          $('#main-outlet').addClass("is_wordpress");

Etc.

Does the TopicView class still exist in js ?

Views have been removed from new versions of Ember.js.

There’s a new component called discourse-topic which should work for your needs.

3 Likes

Thank you ! I will try it !