0
목록에 대해 편집 가능한 콤보 박스를 만들어야합니다. _을 사용하여 템플릿을 js 파일에로드합니다. 새 ComboBox 객체를 만드는 동안 jquery selector를 사용하여 요소를 선택하지만 null 오류의 'parentNode'속성을 읽을 수 없습니다. 여기 jquery 선택기 요소의 null의 'parentNode'속성을 읽을 수 없습니다.
는 자바 스크립트입니다 : 여기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와 선택기로 입력 상자를 선택 어떻게하다 그렇게 그와 관련된 올바른 태그를 반환합니까?