|
|
|
| Проблема такая. Аяксом подгружаю xml файл, создаю на основе него меню. На jquery пишу обработчик для этого меню. Вся проблема в том, что если это меню сразу прописать в коде, то все работает, а если оно генерится то не работает.
$.ajax({
type: "GET",
url: "http://test1.ru/v/vacantions.xml",
dataType: "xml",
success: function(xml) {
var vacancy = "<ul class=\"job-vacancy-menu\">";
$(xml).find('vacantion').each(function(){
vacancy += "<li>\
<a href=\"javascript:void(0)\" class=\"job-vacancy-descshow\">"+$(this).attr('title')+"</a><br>\
LOCATION: "+$(this).attr('location')+"\
<div class=\"job-vacancy-desc\">\
<div class=\"job-vacancy-desc-top\"></div>\
<div class=\"job-vacancy-desc-middle\"> \
<div class=\"job-vacancy-desc-info\">";
$(this).find('blocks').each(function(){
vacancy += "<h3>"+$(this).attr('title')+":</h3> \
<ul> \
</ul>";
});
vacancy += "</div> \
</div>\
<div class=\"job-vacancy-desc-bottom\"></div>\
</div>\
</li>";
});
vacancy += "</ul>";
$("#content-job-vacancy").html(vacancy);
//alert(vacancy);
}
});
$("#content-job-vacancy ul.job-vacancy-menu li").mouseover(function(){
$(this).attr("class","action");
$(this).find(".job-vacancy-desc-info").attr("style","display:block");
}).mouseout(function(){
$(this).attr("class","");
$(this).find(".job-vacancy-desc-info").attr("style","display:none");
});
|
| |
|
|
|
|
|
|
|
для: sanchescom
(27.11.2011 в 11:21)
| |
$.ajax({
type: "GET",
url: "http://test1.ru/v/vacantions.xml",
dataType: "xml",
success: function(xml) {
var vacancy = "<ul class=\"job-vacancy-menu\">";
$(xml).find('vacantion').each(function(){
vacancy += "<li>\
<a href=\"javascript:void(0)\" class=\"job-vacancy-descshow\">"+$(this).attr('title')+"</a><br>\
LOCATION: "+$(this).attr('location')+"\
<div class=\"job-vacancy-desc\">\
<div class=\"job-vacancy-desc-top\"></div>\
<div class=\"job-vacancy-desc-middle\"> \
<div class=\"job-vacancy-desc-info\">";
$(this).find('blocks').each(function(){
vacancy += "<h3>"+$(this).attr('title')+":</h3> \
<ul> \
</ul>";
});
vacancy += "</div> \
</div>\
<div class=\"job-vacancy-desc-bottom\"></div>\
</div>\
</li>";
});
vacancy += "</ul>";
$("#content-job-vacancy").html(vacancy);
//alert(vacancy);
$("#content-job-vacancy ul.job-vacancy-menu li").mouseover(function(){
$(this).attr("class","action");
$(this).find(".job-vacancy-desc-info").attr("style","display:block");
}).mouseout(function(){
$(this).attr("class","");
$(this).find(".job-vacancy-desc-info").attr("style","display:none");
});
}
});
|
| |
|
|
|
|
|
|
|
для: sanchescom
(27.11.2011 в 11:21)
| | почитай про js-шаблонизацию | |
|
|
|
|
|
|
|
для: sanchescom
(27.11.2011 в 11:21)
| | через .live() вешайте обработчики | |
|
|
|
|
|
|
|
для: AlexSol
(27.11.2011 в 16:27)
| | лучше через .bind, я раз так попробовал через .live, у меня с каждым вызовом ф-ции, количество росло пропорционально. | |
|
|
|
|
|
|
|
для: TetRiska
(28.11.2011 в 01:53)
| | не удивительно. live надо указать один раз и не повторять при добавление новых элементов. | |
|
|
|