Я создал jsfiddle , нажмите здесь
, но я не могу понять, как реализовать Ctrl + щелчок по выбранным опциям.
в проектеJS файл после вызова retrieveSelectedClass
, у меня есть запрос http, чтобы получить данные со стороны сервера и отобразить их в пользовательском интерфейсе.Я использую библиотеку для отображения кода: Codemirror
.
var data = {
apexClassName: $scope.selectedName.name
};
var config = {
params: data
};
$http.get("/getApexBody", config).then(getApexBodyCallback, getApexBodyErrorCallback);
function getApexBodyCallback(response) {
if (response.data) {
$scope.apexClassWrapper = response.data;
if (globalEditor1) {
globalEditor1.toTextArea();
}
setTimeout(function(test) {
var editor = CodeMirror.fromTextArea(document.getElementById('apexBody'), {
lineNumbers: true,
matchBrackets: true,
styleActiveLine: true,
extraKeys: {
".": function(editor) {
setTimeout(function() {
editor.execCommand("autocomplete");
}, 100);
throw CodeMirror.Pass; // tell CodeMirror we didn't handle the key
}
},
gutters: ["CodeMirror-lint-markers"],
lint: true,
mode: "text/x-apex"
});
editor.markClean();
editor.on("keyup", function(cm, event) {
var keyCode = event.keyCode || event.which;
if (!ExcludedIntelliSenseTriggerKeys[(event.keyCode || event.which).toString()]) {
if (timeout) clearTimeout(timeout);
timeout = setTimeout(function() {
editor.showHint({
hint: CodeMirror.hint.auto,
completeSingle: false
});
}, 150);
}
});
globalEditor1 = $('.CodeMirror')[0].CodeMirror;
}), 2000
document.getElementById('saveBtn').style.visibility = 'visible';
$scope.isPaneShown = false;
}
}
HTML
<div id="container">
<select ng-model="selectedName" ng-change="retrieveSelectedClass(selectedName, '{{selectedName}}')" ng-options="item.name group by item.groupName for item in names"
class="code-helper" id="code-helperId">
<option value="">Select Option</option>
</select>
</div>
<div style="padding: 1px; position: absolute; margin: 0px; left: 0px; right: 0px; top: 30px; bottom: 30px; width: 100%; height: auto; " loading-pane="isPaneShown">
<textarea ng-model="apexClassWrapper.body" id="apexBody" name="apexBody" style="display: none;" readonly="true">{{apexClassWrapper.body}}</textarea>
</div>
Проблема даже в том, что я улавливаю событие нажатия Ctrlкак это:
if ($window.event.ctrlKey) {}
внутри моего retrieveSelectedClass
, как он откроет ту же HTML-страницу в новой вкладке со значением параметра, уже выбранным в меню выбора
Но я не могучтобы понять, как я реализую Ctrl + клик по значению выбора опции, чтобы открыть его на новой вкладке, с именем файла, выбранным в выпадающем списке выбора, и текстовой области, показывающей тело полученного класса?