我正在尝试添加新的引导程序列表组项,并在其中包含使用for
循环的按钮。
testdiv.append("<a class='list-group-item list-group-item-action'> "
+ "<h6 class='list-group-item-heading'>" + value + "</h6>"
+ "<p class='list-group-item-text'>This requires approval</p>"
+ "<button onclick='approveReq("+ value +")' type='button' class='btn btn-primary'>Approve</button> </a>");
value
是一个在for
循环中创建的变量,因此每次产生不同的结果。 onclick='approveReq("+ value +")'
应该接受此值,因为函数approveReq(value)
需要它。
我不确定我是否正在解释这一点,任何帮助?
答案 0 :(得分:0)
HexButtonControl hbc1 = new HexButtonControl();
hbc1.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
hbc1.VerticalAlignment = System.Windows.VerticalAlignment.Top;
hbc1.Margin = new Thickness(left, top, 0, 0);
HexModelObject hmo1 = new HexModelObject()
{
LabelColor = new SolidColorBrush(Colors.Black),
//RectangleBrush = new SolidColorBrush(Colors.Honeydew),
HexBackground = new SolidColorBrush(Colors.LightBlue),
Move = false,
AssignedUnit = new Unit()
};
Binding b_move = new Binding("Move");
b_move.Source = hmo1;
b_move.Mode = BindingMode.TwoWay;
hbc1.SetBinding(HexButtonControl.MoveProperty, b_move);
Binding b_unit = new Binding("AssignedUnit");
b_unit.Source = hmo1;
b_unit.Mode = BindingMode.TwoWay;
hbc1.SetBinding(HexButtonControl.AssignedUnitProperty, b_unit);
hmo1.AssignedUnit.Strength = UnitStrength.Heavy;
this.myGrid.Children.Add(hbc1);
}
这是你所期待的 请检查此codepen