@@ -7,49 +7,56 @@ title : 'Test Page'
77type : 'Library'
88---
99<div class="ui container">
10- <form class="ui form">
11- <div class="fields">
12- <div class="seven wide field">
13- <label>Card Number</label>
14- <div class="ui fluid button" tabindex="0">Submit Order</div>
15- </div>
16- <div class="three wide field">
17- <label>CVC</label>
18- <input type="text" name="card[cvc]" maxlength="3" placeholder="CVC">
19- </div>
20- <div class="six wide field">
21- <label>Expiration</label>
22- <div class="two fields">
23- <div class="field">
24- <select class="ui fluid dropdown" name="card[expire-month]">
25- <option value="">Month</option>
26- <option value="1">January</option>
27- <option value="2">February</option>
28- <option value="3">March</option>
29- <option value="4">April</option>
30- <option value="5">May</option>
31- <option value="6">June</option>
32- <option value="7">July</option>
33- <option value="8">August</option>
34- <option value="9">September</option>
35- <option value="10">October</option>
36- <option value="11">November</option>
37- <option value="12">December</option>
38- </select>
39- </div>
40- <div class="field">
41- <input type="text" name="card[expire-year]" maxlength="4" placeholder="Year">
42- </div>
43- </div>
44- </div>
45- </div>
46- </form>
10+ <div class="ui basic segment">
11+ 1. After "First" tab is clicked, click the "ClickMe" button. Alert will appear<br />
12+ 2. <b>BUG:</b> When "First" tab is clicked on again, button stops working. Changing <i>cacheType</i> doesnt change anything!<br />
13+ 3. <b>The goal is to run JS once and then leave it be</b>. So scripts must be evaluated once and tab should not reload, if focused on again.
4714</div>
4815
16+ <div class="ui top attached tabular menu">
17+ <a class="active item" data-tab="first">First</a>
18+ <a class="item" data-tab="second">Second</a>
19+ </div>
20+ <div class="ui bottom attached active tab segment" data-tab="first">
21+
22+ </div>
23+ <div class="ui bottom attached tab segment" data-tab="second">
24+
25+ </div>
4926</div>
5027<script>
5128$(document).ready(function() {
52- $('.ui.dropdown').dropdown();
29+ var firstTabContent = "<div id='testfirst'>One <button>ClickMe</button></div> \n" +
30+ "<script type='text/javascript'>\n" +
31+ " $(function() { $('button').click(function() { alert(1) }); $('#testfirst').append('<div>dynamically appended div <b>(will disappear if tab is clicked again!)</b> ' + (new Date()).getTime() + '</div>') });\n" +
32+ "</scr" + "ipt>";
33+
34+ $('.menu .item')
35+ .tab({
36+ cache: true,
37+ cacheType: 'DOM',
38+ evaluateScripts: true,
39+ onFirstLoad: function(tabPath, parameterArray, historyEvent) {
40+ console.log('Initialized tab: ' + tabPath);
41+ },
42+ onLoad: function(tabPath, parameterArray, historyEvent) { //tab selected
43+ console.log('Selected tab: ' + tabPath);
44+ },
45+ apiSettings: {
46+ loadingDuration : 300,
47+ mockResponse : function(settings) {
48+ var response = {
49+ first : firstTabContent,
50+
51+ second : 'Two',
52+
53+ third : 'Three'
54+ };
55+
56+ return response[settings.urlData.tab];
57+ }
58+ }
59+ });
5360});
5461
5562</script>
0 commit comments