我在我的chartbox div中放置了一个复选框。复选框显示良好,但现在我想在复选框更改后执行一些操作。
<input type="checkbox" id="dbox1" onchange="calc();" checkeddata-dojo-type="dijit/form/CheckBox">
function calc() {
alert("123");
}
点击复选框后会出现此错误:
未捕获的ReferenceError:未定义calc
所以我测试了这个:
<input type="checkbox" id="dbox1" onchange="alert("123");" checkeddata-dojo-type="dijit/form/CheckBox"/>
使用此代码会发生以下错误:
SyntaxError:意外的令牌}
Chartbox:
new window.EvmClasses.chartBox(_domnodeId, _portletId, {
"htmlContent": '<input type="checkbox" id="dbox1" onchange="calc();" checkeddata-dojo-type="dijit/form/CheckBox">' + " Minuten bis zur automatischen Aktualisierung",
"left" : 100,
"top" : 0,
"width" : 410,
"z-index" : 9,
"height" : 25,
"bgColorFrom" : "#ffffff",
"bgColorTo" : "#ffffff",
"color" : "#000000"
});
答案 0 :(得分:1)
而不是双引号进入警报
<input type="checkbox" id="dbox1" onchange="alert("123");" checkeddata-dojo-type="dijit/form/CheckBox"/>
将其替换为单引号,如下所示。
<input type="checkbox" id="dbox1" onchange="alert('123');" checkeddata-dojo-type="dijit/form/CheckBox"/>
答案 1 :(得分:0)
尝试在窗口范围中定义public class SessionView : BaseViewModel
{
private SessionView _sessionView;
public int SessionId { get; set; }
public SessionView()
{
_sessionView = new SessionView();
_sessionView.data = from s in db.Sessions
where s.SessionId == SessionId
select new SessionView
{
CourseId = s.CourseId
// ... lots of other properties
}).FirstOrDefault();
}
private SessionView data
{
get
{
return _sessionView.data
}
set { }
}
public int CourseId { get { return data.CourseId; } set { } }
// ... lots of other properties
}
函数:
using (var db = new DatabaseContext())
{
var person = db.Persons.Single(p => p.PersonId == personId); // Tracks your person
person.Dogs.Add(new Dog("Droopy"));
db.SaveChanges();
}