我试图通过vector<Item*> inventory;
string usrInptOptn = "default";
string usrInptOptn2 = "default";
while (true) {
// Get user choice
cout << "\nEnter (p)rint, (a)dd, (u)pdate, (r)emove, or (q)uit: ";
getline(cin, usrInptOptn);
// Process user choice
if (usrInptOptn.size() == 0) {
continue;
}
else if (usrInptOptn.at(0) == 'p') {
PrintInventory(inventory);
}
else if (usrInptOptn.at(0) == 'a') {
cout << "\nEnter (b)ook or (p)roduce: ";
getline(cin, usrInptOptn);
if (usrInptOptn2.at(0) == 'b') {
cout << "needs work..." << endl; //Something fishy going on here...
}
else if (usrInptOptn2.at(0) == 'p') {
cout << "something isn't working here" << endl;
inventory = AddItemToInventory(inventory);
}
}
else if (usrInptOptn.at(0) == 'u') {
inventory = UpdateItemQtyInInventory(inventory);
}
else if (usrInptOptn.at(0) == 'r') {
inventory = RemoveItemFromInventory(inventory);
}
else if (usrInptOptn.at(0) == 'q') {
cout << "\nGood bye." << endl;
break;
}
}
标记中的href属性调用基本的javascript函数。我之前已经做了无数次,但是现在每个浏览器都在jref javascript调用中抛出jQuery中的异常,而且有些浏览器选择不运行它而是打开一个空白的新窗口。在这一点上我只是感到困惑。有什么想法吗?
HTML:
<a>
的JavaScript / jQuery的:
<td>
<a href="javascript:showQuote(12);" data-toggle='modal' target='#quoteBox'>
View Quote
</a>
</td>
Chrome是唯一可以使用它的浏览器(它仍会引发错误)。我通过一些在线验证器运行了它们,它们变得干净了。
另外,我使用的是jQuery版本1.11.3。
答案 0 :(得分:3)
最好在&#34; jquery&#34;风格。
更新了答案 - 使用当前控件ID
<td>
<a href="" data-toggle='modal' id="12" class="mylink" target='#quoteBox'>
View Quote
</a>
</td>
在Document.Ready ..
$('.mylink').on('click',function(event){
event.preventDefault();
var id = $(this).attr('id');
$("#spot").load("viewQuote.php?id=" + id);
$('#modal').modal('show');
})
答案 1 :(得分:0)
HTML
<td><a href="javascript:showQuote(12,event);" data-toggle='modal' target='#quoteBox'>View Quote</a></td>
的Javascript
function showQuote(id,event){
$("#spot").load("viewQuote.php?id=" + id);
$('#modal').modal('show');
event.preventDefault();
return false;
}