I have an item view that looks like this:

MyView = Marionette.ItemView.extend({
  template: "#static-template"

  onRender: function() {
    console.log($('#static-template').val())
  }
});

I want to use jQuery to select the #static-template element, but I am unable to do. How can I select this element with jQuery inside a Marionette.ItemView?

有帮助吗?

解决方案

Use this.$el. In your case, this.$el.attr("value");

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top