Issue #1553Opened October 31, 2018by nine-2-five0 reactions

Use jQuery in view update

Question

I need to manipulate DOM with jQuery, when my model changes, but it seems the View is unaware of it.

view: defaultView.extend({
        init() {
          this.listenTo(this.model, 'change:model-twig-path', this.updateContent);
        },
        updateContent() {                        
          var twig_path = this.model.get('model-twig-path');
          var viewEl = this.el;

          request('http://localhost:8080/content/hr.json', function(err, response, data){
              request('http://localhost:8080/static/pharma-bio/views/blocks/' + twig_path, function(err, response, twig_template){
                var template = Twig.twig({data: twig_template});                    

                viewEl.innerHTML = template.render(data);
                //I'd like to use jQuery instead of innerHTML
              });      
          });                                 
        },
      }),

Answers (3)

yomeshguptaOctober 31, 20180 reactions

Yes, $ is available would be available under editor.$

However, I am not sure if that would be full fledged jQuery. You can always insert custom JS scripts in the canvas during initialisation. If you want, you can add jQuery there and then it would be available everywhere.

artfNovember 3, 20180 reactions

@isvaljek use this.$el instead of this.el

lock[bot]November 3, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.