Мне нужно сделать редактируемый список со списком, я использую _ для загрузки шаблона в файл js. При создании нового объекта ComboBox я использую селектор jquery для выбора элемента, но я получаю свойство not not parent 'parentNode' с нулевой ошибкой.Невозможно прочитать свойство «parentNode» из null элемента jquery selector
Вот Javascript:
var deps = [
'jquery', 'underscore', 'lib/combobox', 'dialogs/FlowNode',
'text!dialogs/choose-feature.html'
];
define(deps, function($, _, combobox, FlowNode, ChooseFeatureTmpl) {
var ChooseFeatureTemplate = _.template(ChooseFeatureTmpl);
return {
create: function(transition) {
var node = FlowNode.create(ChooseFeatureTemplate, transition);
// add the controls onto the FlowNode for displaying
// the limiting of features
$(node).on('render', function() {
var typecombo = new ComboBox($('input[name="select-type"]'));
var organism_selector = '#' + node.uid() + ' select[name="select-organism"]';
var type_selector = '#' + node.uid() + ' input[name="select-type"]';
var feature_selector = '#' + node.uid() + ' select[name="select-feature"]';
var changeFn = function() {
var organism = $.parseJSON(
unescape($(organism_selector + ' option:selected').data('organism'))
);
var type = $.parseJSON(
unescape($(type_selector + ' option:selected').data('type'))
);
// clear out the feature select box
var $featureselect = $(feature_selector);
$featureselect.empty();
// refill the feature select box
$.each(node.data().features, function(id, feature) {
if (feature.organism == organism.id && feature.type == type.name) {
var $option = $('<option />').text(feature.name + " - " + feature.uniquename)
.attr('data-feature', escape(JSON.stringify(feature)));
$featureselect.append($option);
}
});
};
$(document).on('change', organism_selector, changeFn);
$(document).on('change', type_selector, changeFn);
});
return node;
}
};
Вот часть HTML, связанный с этим списком:
<div id="<%= uuid %>" class="center-block">
<div>
<label for="select-type">Type</label>
<input type="text" name="select-type" class="select-type form-control" id="type">
<span>▼</span>
<div class="dropdownlist">
<% _.each(types, function(type, id) { %>
<option data-type="<%= escape(JSON.stringify(type)) %>"><%= type.name %></option>
<% }); %>
</div>
Мой вопрос, как я могу выбрать поле ввода с селектором Jquery так, что возвращает правильный тег, связанный с ним?