我使用php foreach獲取使用ajax分頁評分的元素列表,每個元素使用bootstrap popover進行評分(意味着評分html在'data-content'attr )。在第一次加載一切正常,我可以看到其他頁面,當我點擊分頁鏈接,但是當Ajax已經加載引導彈窗沒有顯示。
如何在ajax加載後在bootstrap popover中獲取元素
- 如何獲得'data-id'和'data-name'屬於'rate-multi-select'類。
- 如何獲得輸入值。
- 如何獲得'multi-ajax-user-rating'類的ID屬性。
這裏是酥料餅的評價:
$('[data-toggle="popover"]').popover({html:true}).click(function(e) {e.preventDefault();});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>test</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>
<div class="title-multi-rating popovered-rating popovered" title="Rate this!?" data-container="body" data-toggle="popover" data-placement="bottom" data-content="<form method='POST' action='' class='orb-form orb-rating-form' id='orb-form'>
<section>
<label class='label'></label>
<div class='rating rate-multi-select' id='rate-select' data-id='118' data-name='people'>
<div class='multi-ajax-user-rating' id='0'></div>
<input type='radio' name='stars-rating' value='100' id='stars-rating-100'>
<label for='stars-rating-100' title='Juste magique :)'><i class='fa fa-heart'></i></label>
<input type='radio' name='stars-rating' value='90' id='stars-rating-90' >
<label for='stars-rating-90' title='Excellent'><i class='fa fa-heart'></i><label>
</div>
</section>
<!--<button type='submit' name='submit-rating' class='btn btn-success' value='ok'>Evaluer</button>-->
</form>">
<span><img class="rating-image" src="/assets/images/Icons/icon-hate-large.png" alt=""/><strong>Element1</strong></span>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>
我沒有看到任何AJAX調用 – Nicholas