我有一個div
動態添加,就是當你選擇在grid
一個tr
它增加了一個班,grid-row-selected
,這凸顯了tr
內的網格。所以我想要做的是創建一個jQuery或JavaScript function
,當tr
被突出顯示並添加類時,將在ibox-tools
中創建一個按鈕。此外,如果grid-row-selected
被刪除,按鈕也是如此。這是我現在沒有工作(不會添加按鈕)。JQuery的添加按鈕的div
JQUERY
/* Function is called when a tr is selected with the grid-row class */
$("tr.grid-row").click(function() {
/* Checks if this class is selected and has grid-row-selected class */
if ($(this).hasClass(".grid-row-selected")) {
/* Adds button to ibox-tools in div */
$(".ibox-tools").add($('<input type="button" value="new button"/>'));
}
});
HTML
<div class="ibox-title">
// Where the button should be populated into
<div class="ibox-tools">
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#enlargeGraphOneModal" data-content="#ibox-2"></button>
</div>
</div>
<div class="ibox-content" id="ibox-2">
<div class="content active row" id="graphOneData" style="overflow:auto">
<!--GRID DYNAMICALLY ADDED-->
@Html.Grid(Model).Columns(columns =>
{
columns.Add(scenario => scenario.DisplayName).Titled("Display Name").Sortable(true);
columns.Add(scenario => scenario.Description).Sortable(true);
columns.Add(scenario => scenario.ModifiedBy).Titled("Modified By").Sortable(true);
columns.Add(scenario => scenario.ModifiedOn).Titled("Modified On").Sortable(true);
columns.Add(scenario => scenario.StartYear).Titled("Start Year").Sortable(true);
columns.Add(scenario => scenario.EndYear).Titled("End Year").Sortable(true);
}).WithPaging(20).Sortable()
</div>
</div>
哪裏是 「易寶工具」 CSS類在HTML –
@VimalanJayaGanesh你意思是我在哪裏打電話給我的CSS中的鏈接到我的HTML或什麼是IBOX的CSS完全? – Markus
你正試圖用類「.ibox-tools」添加一個按鈕到控件。首先,我無法在html中看到「.ibox-tools」類。例如:https://jsfiddle.net/99x50s2s/141/(你必須有一個類「ibox-tools」的控件來添加另一個控件。 –