私はAJAXリクエストからデータをロードしたいツールチップのbootstrapを持っています。リクエストのテキストはツールチップのtitle
プロパティです。私のAJAXリクエストは正常に動作しますが、2つの問題があります。ブートストラップのツールチップをAJAXの呼び出し結果に設定します
- なぜAJAXコールのデータがツールチップに入り込まないのですか?
ttManager
オブジェクトを使用してツールチップの状態をカプセル化するにはどうすればよいですか?私はかなり確信している現在
、ときに、ページが最初にロードし、私は、コンソールに#btnSubmit
をクリックして、私は success
を参照してくださいとはconsole.log(ttManager)ライン
$(document).ready(function() {
//this object's title attribute will be the value of ttManager.title seen below
var ttManager = {
title: '',
setTitle: function (data) {
this.title = data;
}
}
var ajaxCall = function() {
//this returns the top five results of text from a query
$.ajax({
type: "POST",
contentType: "application/json",
url: "Service.asmx/GetDrugs",
dataType: "json",
success: function (data) {
console.log('success');
ttManager.title = data.d;
//inside this function I want to set ttManager.title equal to the data.d
console.log(ttManager);
},
error: function (xhr) {
console.log('failed: ' + xhr.status);
}
});
}
$('#btnSubmit').tooltip({
//reference to ajax call
//title is the attribute responsible for displaying text in the tooltip
//I need to use a reusable object to set the text property instead of referencing ajaxCall
//would it be better if there below were title: ttManager.title?
title: ajaxCall,
trigger: 'click',
placement: 'right'
});
});
から正しいデータどこかでコールバック関数が必要だが、私はどこにいるのかわからない。将来のポインターも高く評価されます。ありがとう。
どのBSのバージョンを使用していますか? – PSL
私はブーストラップ3.0を使用しています – wootscootinboogie