私は何をjqueryにプロトタイプに変換しようとしています。ajaxの投稿結果でjqueryを更新する
私のプロトタイプは、jQueryのに上記の変更方法
$$(".user-link").each(function(el){
el.observe("mouseover", function(event) {
_selectedLinkEl = el;
_detailEl = event.element().next();
_detailEl.show();
_href=el.readAttribute('href').split("/")[2];
new Ajax.Request('/users/user_detail/?name='+_href, {
onSuccess: function(transport) {
if (200 == transport.status)
_detailEl.update(transport.responseText);
}
});
_body.observe("mouseover", _bodyMouseOverFunction);
});
});
var _bodyMouseOverFunction = function(event) {
if(event.element() != _selectedLinkEl &&
event.element() != _detailEl &&
!event.element().ancestors().include(_detailEl)) {
_detailEl.hide();
_body.stopObserving("mouseover", _bodyMouseOverFunction);
}
};
のですか?
user-linkは、多くのリンクに存在するクラス名です。このリンク上でマウスでajaxリクエストを実行しようとしています。
EDIT:
私は私が更新するために、どのようにAJAXリクエストの結果とアラートを取得しています jQueryのよう(ドキュメント).ready(関数(){
jQuery(".user-link").hover(function() {
jQuery(this).next().show();
var href=jQuery(this).attr("href");
href= href.split("/")[2];
jQuery.post('http://localhost:3000/users/user_detail/?name='+href,
function(data){
alert("Data Loaded: " + data);
}
);
}); //hover
});// doc ready
を試してみました。結果の要素がうまくいけば、これはあなたが始めるのに役立つだろう??
1. jqueryを学ぶ2.プロトタイプを学ぶ3. – mkoryak