Emilly
Emilly

Reputation: 89

Proper UI manipulation using Backbone

I am having issue with UI manipulation:

I have this code:

var View = Backbone.View.extend({
el : '[data-container]',
ui : {
    something : '[data-something]'
},

Then I can use:

this.ui.something.show().

This is plain jQuery selector, which will disable all input elements within the div.

$("#something :input").attr("disabled", true);

I am trying to do the same thing using this.ui selector, but how do I pass :input? If I use

this.ui.something.attr("disabled", true);

it disables the div, but not the elements inside it.

Some ideas?

Upvotes: 2

Views: 71

Answers (3)

Draculater
Draculater

Reputation: 2278

Assuming an element actually has a data attribute of data-something, $('input',this.ui.something).attr(...) should work. All that is doing is finding all inputs inside elements that have data-something attribute

http://jsfiddle.net/sailorob/pvntR/

Edit: Just to clarify further, comma delimiter in the selector like jQuery(el1,el2) is the same as using jQuery(el2).find(el1);

Upvotes: 2

hamstu
hamstu

Reputation: 1644

this.ui.something.find("input").attr("disabled", true);

Upvotes: 0

Balint Bako
Balint Bako

Reputation: 2560

That selector is not correct, it should be $("#something input") and this selector should work in the View too

Upvotes: 0

Related Questions