Всем привет! Помогите разобраться как сделать программно выборку элемента "SELECT", на котором висит скрипт. Я уже разобрался как выбирать сам элемент, как запускать скрипты, но плохо понимаю Java, помогите разобраться?
Вот код страницы на которой расположен компонент "Select" и есть исполняющий скрипт, но он как-то странно привязан к элементу, не могу понять как.
Код страницы:
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193. 194. 195. 196. 197. 198. 199. 200. 201. 202. 203. 204. 205. 206. 207. 208. 209. 210. 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223. 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234. 235. 236. 237. 238. 239. 240. 241. 242. 243. 244. 245. 246. 247. 248. 249. 250. 251. 252. 253. 254. 255. 256. 257. 258. 259. 260. 261. 262. 263. 264. 265. 266. 267. 268. 269. 270. 271. 272. 273. 274. 275. 276. 277. 278. 279. 280. 281. 282. 283. 284. 285. 286. 287. 288. 289. 290. 291. 292. 293. 294. 295. 296. 297. 298. 299. 300. 301. 302. 303. 304. 305. 306. 307. 308. 309. 310. 311. 312. 313. 314. 315. 316. 317. 318. 319. 320. 321. 322. 323. 324. 325. 326. 327. 328. 329. 330. 331. 332. 333. 334. 335. 336. 337. 338. 339. 340. 341. 342. 343. 344. 345. 346. 347. 348. 349. 350. 351. 352. 353. 354. 355. 356. 357. 358. 359. 360. 361. 362. 363. 364. 365. 366. 367. 368. 369. 370. 371. 372. 373. 374. 375. 376. 377. 378. 379. 380. 381. 382. 383. 384. 385. 386. 387. 388. 389. 390. 391. 392. 393. 394. 395. 396. 397. 398. 399. 400. 401. 402. 403. 404. 405. 406. 407. 408. 409. 410. 411. 412. 413. 414. 415. 416. 417. 418. 419. 420. 421. 422. 423. 424. 425. 426. 427. 428. 429. 430. 431. 432. 433. 434. 435. 436. 437. 438. 439. 440. 441. 442. 443. 444. 445. 446. 447. 448. 449. 450. 451. 452. 453. 454. 455. 456. 457. 458. 459. 460. 461. 462. 463. 464. 465. 466. 467. 468. 469. 470. 471. 472. 473. 474. 475. 476. 477. 478. 479. 480. 481. 482. 483. 484. 485. 486. 487. 488. 489. 490. 491. 492. 493. 494. 495. 496. 497. 498. 499. 500. 501. 502. 503. 504. 505. 506. 507. 508. 509. 510. 511. 512. 513. 514. 515. 516. 517. 518. 519. 520. 521. 522. 523. 524. 525. 526. 527. 528.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
<link rel="shortcut icon" href="/Content/Images/favicon.ico" type="image/x-icon" />
<title>Курсы</title>
<link href="/Content/jquery-ui-1.8.18__3.3.41.25369.css" rel="stylesheet" /><link href="/Content/olimp__3.3.41.25369.css" rel="stylesheet" /><link href="/Content/olimp.controls__3.3.41.25369.css" rel="stylesheet" />
<!--[if IE]><link rel="stylesheet" href="/Content/olimp.ie.css" /><![endif]-->
<!--[if IE 8]><link rel="stylesheet" href="/Content/olimp.ie8.css" /><![endif]-->
<!--[if lt IE 8]><link rel="stylesheet" href="/Content/olimp.ie7.css" /><![endif]-->
<!--[if lte IE 6]><link rel="stylesheet" href="/Content/olimp.ie6.css" /><![endif]-->
<script type="text/javascript" src="/Scripts/ready.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/jquery-1.7.1.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/jquery-ui-1.8.19.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/jquery.unobtrusive-ajax.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/jquery.validate.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/jquery.validate.unobtrusive.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/knockout-2.1.0__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/knockout.mapping-2.3.0__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/doT.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/jquery.cookie__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/q.min__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/Olimp__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/Olimp.ViewModels__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/Olimp.Controls__3.3.41.25369.js"></script><script type="text/javascript" src="/Scripts/jquery.ui.datepicker-ru.js"></script>
<script>$.Olimp.ensureWorkplaceToken('62d52c3d-f674-42b3-b4ac-40b1ac75c076')</script>
<!--[if lt IE 7]>
<style>#no-feature-message { position: absolute; top: 6px; }</style>
<![endif]-->
<title>
</title></head>
<body >
<script>
domready(function () {
if (!$.Olimp.hasWorkplaceToken()) {
var div = document.createElement("div");
div.className = 'error-message no-feature-message';
div.style['width'] = '400px';
div.style['margin-left'] = '-200px';
div.innerHTML = '<b>Отключены Cookie.</b> Для корректной работы системы необходимо включить Cookie в настройках браузера и обновить страницу.';
document.body.appendChild(div);
}
});
</script>
<noscript>
<div class="error-message no-feature-message" style="width: 400px; margin-left: -200px;"><b>Отключен JavaScript.</b> Для корректной работы системы необходимо разрешить выполнение сценариев в настройках браузера и обновить страницу.</div>
</noscript>
<div class="wrapper">
<div id="status">
<form action="/Auth/Logout" id="logout-form" method="post"></form><script type="text/javascript">
function logout() { $('#logout-form')[0].submit() }
</script>
<a class="status-link" href="javascript: logout()">
<div class="icon icon-exit"></div>
<div class="text">Выйти из системы</div>
</a>
</div>
<div id="head">
<a href="/" class="logo" >
<img src="/Content/Images/logo.gif" alt="На главную" />
</a>
<div class="navigation">
<div class="tabs">
<div class="wrap">
<a href="/Admin/ModeRegistrations">Администрирование</a><a href="/Admin/Courses">Материалы</a><a href="/Admin/Archive/ArchiveSearch">Архив</a><a href="/Admin/Activity/Current">Активность</a><a href="/Admin/NormativeInfo">Нормативы</a><a class="active" href="/Admin/Info/TreeInfo">Курсы</a><a href="/Admin/Group">Регистрация</a><a href="/Admin/Profile/Manage">Профили</a>
</div>
</div>
<div class="body">
<div class="links"><a class="active" href="/Admin/Info/TreeInfo">Информация о курсах</a><a href="/Admin/GeneratorTests">Генератор тестов</a><a href="/Admin/CreateCourse">Создание учебных курсов</a></div>
</div>
</div>
</div>
<div id="main">
<script type="text/javascript">
$(function() { $('#head .navigation').olimpmenu() })
</script>
<script type="text/javascript">
function showCourseInfo(materialId) { $('#course-info-dialog').data('viewModel').materialId(materialId) }
function showQuestionInfo() {
var materialId = $('#course-info-dialog').data('viewModel').materialId(),
questionId = this.Id(),
dialog = $('#question-info-dialog');
dialog.load(
'/Admin/Archive/QuestionInfo',
{ materialId: materialId, questionId: questionId },
function() { dialog.olimpdialog('open') });
}
$(function() {
var viewModel = {
selectedTicketTitle: ko.observable(''),
allowDeleteTickets: ko.observable(false),
courseName: ko.observable(''),
tickets: ko.observableArray([]),
ticketSize: ko.observable(),
maxErrors: ko.observable()
},
dialog = $('#course-info-dialog'),
selectedTicket = ko.observable(),
materialId = ko.observable();
viewModel.selectedTicket = ko.computed({
read: function() { return selectedTicket() },
write: function(value) {
var self = this;
if (!self.materialId())
return;
$.post('/Admin/Info/GetTicketInfo',
{ materialId: self.materialId(), ticketId: value.id() },
function(tableData) {
$('#ticket-questions').data('viewModel').setRows(tableData)
self.selectedTicketTitle(value.title())
selectedTicket(value);
dialog.olimpdialog('option', 'position', 'center').olimpdialog('open');
},
'json')
},
owner: viewModel
}).extend({ throttle: 100 });
viewModel.materialId = ko.computed({
read: function() { return materialId(); },
write: function(value) {
var self = this;
materialId(value);
$.post('/Admin/Info/GetCourseInfo', { id: value }, function(json) {
ko.mapping.fromJS(json, {}, self)
}, 'json');
},
owner: viewModel
})
var courseInfoNode = $('#course-info');
ko.applyBindings(viewModel, courseInfoNode[0])
courseInfoNode.find('select').combobox();
ko.applyBindings({
allowDeleteTickets: ko.computed(function() { return viewModel.allowDeleteTickets() }),
deleteTicket: function() {
if (!confirm('Билет будет удален. Продолжить?')) return;
$.post('/Admin/Info/DeleteTicket',
{ materialId: viewModel.materialId(), ticketId: viewModel.selectedTicket().id() },
function() {
viewModel.tickets.remove(viewModel.selectedTicket())
if (!viewModel.tickets().length) {
viewModel.selectedTicket(null);
viewModel.selectedTicketTitle('');
viewModel.allowDeleteTickets(false);
$('#ticket-questions').data('viewModel').setRows({ rows: [], rowsCount: 0 })
}
})
},
pretifyButton: function() { $('#ticket-actions button').olimpbutton() }
}, $('#ticket-actions')[0]);
dialog.data('viewModel', viewModel)
.olimpdialog({ autoOpen: false, draggable: false, resizable: false, modal: true, width: '70%', fixedHeight: 0.9, title: 'Информация по курсу' });
$('#question-info-dialog').olimpdialog({
autoOpen: false, modal: true, resizable: false, draggable: false, width: '60%', title: 'Информация о вопросе' });
})
</script>
<h1>Информация о курсах</h1>
<div class="block">
<ul id="MaterialsCatalogue-637648010709303119" class="catalogue without-checkboxes" class="ui-widget ui-widget-content materials-tree" data-bind="template: { name: 'nodeTemplate_doTEngine', templateEngine: $root.templateEngine }"></ul><div style="clear:both;"></div><script id="defaultMaterialNameTemplate_doTEngine" type="text/html">
<span>{{= it.$data.code() }} {{= it.$data.name() }}</span>
</script>
<script id="materialTemplate_doTEngine" type="text/html">
{{~ it.$data.materials() :material:mi }}
{{ var materialContext = it.createChildContext(material); }}
<li class="-has-dot-binding" data-dot-context="{{= materialContext.$$contextId }}" data-dot-bind="attr: { 'class': listItemClass }">
<div class="gap"> </div>
<div class="node-caption">
{{? it.$root.showCheckBoxes }}
<input type="checkbox" class="checker -has-dot-binding" name="{{= it.$root.checkBoxesName }}" value="{{= material.id }}" data-dot-context="{{= materialContext.$$contextId }}" data-dot-bind="checked: selected" />
{{?}}
<div class="{{= material.iconClass() }}"></div>
{{? !it.$root.materialTemplate }}
<div class="material-name">{{= material.caption }}</div>
{{??}}
<div class="material-name">
{{= materialContext.renderTemplate(it.$root.materialTemplate, material) }}
</div>
{{?}}
</div>
</li>
{{~}}
</script>
<script id="nodeTemplate_doTEngine" type="text/html">
{{~ it.$data.nodes() :node:ni }}
{{ var nodeContext = it.createChildContext(node); }}
<li class="{{= ko.utils.unwrapObservable(node.listItemClass) }}">
<div class="node-caption">
{{? node.available }}
<div class="-has-dot-binding" data-dot-context="{{= nodeContext.$$contextId }}" data-dot-bind="attr: { 'class': expandeeClass }, click: $root.toggleExpand"></div>
{{?}}
<div class="gap"> </div>
{{? node.available }}
{{? it.$root.showCheckBoxes }}
<input type="checkbox" class="checker -has-dot-binding" data-dot-context="{{= nodeContext.$$contextId }}" data-dot-bind="checked: checked" />
{{?}}
<div class="-has-dot-binding" data-dot-context="{{= nodeContext.$$contextId }}" data-dot-bind="attr: { 'class': nodeNameClass }">
<span class="-has-dot-binding" data-dot-context="{{= nodeContext.$$contextId }}" data-dot-bind="click: $root.toggleExpand">{{= ko.utils.unwrapObservable(node.name) }}</span>
</div>
{{??}}
<div class="-has-dot-binding" data-dot-context="{{= nodeContext.$$contextId }}" data-dot-bind="attr: { 'class': nodeNameClass }">
<span>{{= ko.utils.unwrapObservable(node.name) }}</span>
</div>
{{?}}
</div>
<div style="clear:both;"></div>
{{? !node.dynamicContent }}
<ul class="{{= node.subListClass() }} -has-dot-binding" data-dot-context="{{= nodeContext.$$contextId }}" data-dot-bind="visible: expanded">
{{= nodeContext.renderTemplate(node.template(), node) }}
</ul>
{{??}}
<div class="-has-dot-binding" data-dot-context="{{= nodeContext.$$contextId }}" data-dot-bind="if: dynamicData">
<div data-bind="visible: expanded">
<div data-bind="template: { name: $root.dynamicContentTemplate, data: dynamicData }"></div>
</div>
</div>
{{?}}
</li>
{{~}}
</script> <script type="text/javascript">$(function(){var element = $('#MaterialsCatalogue-637648010709303119'), viewModel = null;$.post('/Admin/Info/GetCourse', function(json){viewModel = new MaterialsTree(element, json, {id:'MaterialsCatalogue-637648010709303119',templateEngine: 'doTEngine',checkboxes:false,materialsLink:'javascript:showCourseInfo({id});'});element.data('viewModel', viewModel);ko.applyBindings(viewModel, element[0]);}, 'json');});</script></div>
<div id="course-info-dialog">
<script id="delete-button-template" type="text/html">
<button data-bind="click: deleteTicket">Удалить билет</button>
</script>
<div id="course-info">
<h1 data-bind="text: courseName"></h1>
<div class="block">
<table class="form-table">
<tr class="first">
<th>Количество билетов</th>
<td data-bind="text: tickets().length"></td>
</tr>
<tr>
<th>Количество вопросов в билете</th>
<td data-bind="text: ticketSize"></td>
</tr>
<tr>
<th>Количество допустимых ошибок</th>
<td data-bind="text: maxErrors"></td>
</tr>
<tr class='last'>
<th>Билеты</th>
<td>
<select data-bind="
options: tickets,
optionsText: 'title',
value: selectedTicket">
</select>
</td>
</tr>
</table>
</div>
<h1 data-bind="text: selectedTicketTitle"></h1>
</div>
<script id="question-info-action" type="text/html">
<a href="#" class="icon icon-info action" data-bind="click: showQuestionInfo" title="Просмотреть вопрос"></a>
</script>
<script id="answer-result" type="text/html">
<!-- ko if: Correct -->Правильный ответ
<!-- /ko -->
<!-- ko ifnot: Correct -->Неправильный ответ
<!-- /ko -->
</script><script id="question-template" type="text/html">
<div data-bind="html: $data.Text"></div>
<div id="question-main-img-result" style="width: 40%;" data-bind="html: $data.QuestionMainImg"></div>
</script>
<script id="question-template-result" type="text/html">
<div data-bind="html: $data.Question"></div>
<div id="question-main-img-result" style="padding-right: 10px" data-bind="html: $data.QuestionMainImg"></div>
</script><div class="block">
<script id="tableHeadTemplate" type="text/html">
<tr>
<!-- ko if: $root.rowHighlighting -->
<th class="highlight"></th>
<!-- /ko -->
<!-- ko if: actions().length -->
<!-- ko if: $root.headerActions -->
<th class="min-size" data-bind="foreach: $root.actions">
<!-- ko ifnot: $data.templateId --> <!-- /ko -->
<!-- ko if: $data.templateId -->
<!-- ko template: { name: templateId, data: { _header:true }, templateEngine: $root.tbodyEngine } --> <!-- /ko -->
<!-- /ko -->
</th>
<!-- /ko -->
<!-- ko ifnot: $root.headerActions -->
<th class="min-size"> </th>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: $root.checkboxes -->
<th class="min-size checkbox"><input type="checkbox" data-bind="checked: allChecked" /></th>
<!-- /ko -->
<!-- ko foreach: columns -->
<th data-bind="style: style">
<a data-bind="text: caption, attr: _attrs, click: $root._sort"></a>
<!-- ko if: $root.sorting -->
<span data-bind="attr: { 'class': sortClass }"></span>
<!-- /ko -->
</th>
<!-- /ko -->
</tr>
</script>
<script id="tableBodyTemplate" type="text/html">
<!-- ko foreach: rows -->
<tr data-bind="attr: { 'class': _className }, click: $root._rowHighlight.bind($data)">
<!-- ko if: $root.rowHighlighting -->
<td class="highlight"></td>
<!-- /ko -->
<!-- ko if: $root.actions().length -->
<!-- ko ifnot: _isLocked -->
<td class="actions" data-bind="foreach: $root.actions">
<!-- ko ifnot: $data.templateId -->
<a data-bind="attr: attrs, click: $root._rowAction.bind($data, $parent)"></a>
<!-- /ko -->
<!-- ko if: $data.templateId -->
<!-- ko template: { name: templateId, data: $parent } --> <!-- /ko -->
<!-- /ko -->
</td>
<!-- /ko -->
<!-- ko if: _isLocked -->
<td class="actions">
<a class="icon icon-lock-small-active action" title="Действия заблокированы"></a>
</td>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: $root.checkboxes -->
<td class="checkbox">
<input type="checkbox" data-bind="checked: _checked" />
</td>
<!-- /ko -->
<!-- ko foreach: $root.columns -->
<!-- ko if: $data.templateId -->
<td data-bind="template: { name: templateId, data: $parent}"></td>
<!-- /ko -->
<!-- ko ifnot: $data.templateId -->
<td data-bind="html: $parent[$data.name]"></td>
<!-- /ko -->
<!-- /ko -->
</tr>
<!-- /ko -->
</script>
<script id="tableGroupsTemplate" type="text/html">
<!-- ko foreach: groups -->
<tr class="odd">
<td class="grouping" data-bind="attr: { colSpan: $root.columnsCount }, text: name"></td>
</tr>
<!-- ko template: { name: 'tableBodyTemplate', data: $data } -->
<!-- /ko -->
<!-- /ko -->
</script>
<script id="tablePagingTemplate" type="text/html">
<!-- ko if: checkboxes -->
<div class="selected-items-count">
<span>выбрано: </span>
<span data-bind="text: selectedItemsCount"></span>
</div>
<!-- ko foreach: selectedIds -->
<input type="hidden" data-bind="attr: { name: $root.checkboxesName, value: $data }" />
<!-- /ko -->
<!-- /ko -->
<div class="pages">
<a href="#" class="icon icon-left" data-bind="click: paging.leftPage"></a>
<div class="links">
<!-- ko foreach: paging.pages -->
<!-- ko if: isSeparator -->
<span class="separator">...</span>
<!-- /ko -->
<!-- ko ifnot: isSeparator -->
<a href="#" data-bind="text: number, attr: { 'class': selectedClass }, click: $root.paging.select"></a>
<!-- /ko -->
<!-- /ko -->
</div>
<a href="#" class="icon icon-right" data-bind="click: paging.rightPage"></a>
</div>
<div class="total">
<span>на странице:</span>
<select data-bind="
optionsText: function(item) { return item === 99999 ? 'Все' : item },
options: paging.rowAmounts,
value: paging.size">
</select>
</div>
<div class="status">
<span>результаты</span>
<span data-bind="text: paging.rowsSpan"></span><span> из</span>
<span data-bind="text: rowsCount"></span>
</div>
</script>
<script id="tableButtonsTemplate" type="text/html">
<!-- ko if: adding -->
<button type="button" data-bind="text: adding.text, click: adding.action"></button>
<!-- /ko -->
<!-- ko foreach: tableActions -->
<button type="button" data-bind="text: text, style: style, click: $root._tableAction.bind($data)"></button>
<!-- /ko -->
</script>
<script id="tableTemplate" type="text/html">
<div class="body">
<table cellpadding="0" cellspacing="0">
<thead data-bind="template: { name: 'tableHeadTemplate', data: $data }"></thead>
<tbody data-bind="template: { name: $root.tbodyTemplate, data: $data, templateEngine: $root.tbodyEngine }"></tbody>
</table>
</div>
<!-- ko if: paging -->
<div class="paging" data-bind="template: { name: 'tablePagingTemplate', data: $data, afterRender: paging.reset }"></div>
<!-- /ko -->
<!-- ko if: buttons -->
<div class="buttons" data-bind="template: { name: 'tableButtonsTemplate', data: $data }"></div>
<!-- /ko -->
</script>
<div class="table" data-bind="template: 'tableTemplate'" id="ticket-questions"></div><script type="text/javascript">$(function() { var table=$('#ticket-questions'), viewModel=new Table([{'name':'Number','caption':'№'},{'name':'Text','caption':'Вопрос','templateId':'question-template'}], {sorting:false,paging:false,actions:[new RowAction('', null, {templateId:'question-info-action'})]});table.data('viewModel', viewModel);ko.applyBindings(viewModel, table[0]);})</script></div>
<div id="ticket-actions" data-bind="if: allowDeleteTickets">
<div data-bind="template: {
name: 'delete-button-template',
afterRender: pretifyButton }">
</div>
</div>
</div>
<div id="question-info-dialog"></div>
</div>
<div id="foot"></div>
</div>
</body>
</html>
понял что нужно запустить скрипт, вот какой только?
|