diff --git a/boards/static/js/refpopup.js b/boards/static/js/refpopup.js --- a/boards/static/js/refpopup.js +++ b/boards/static/js/refpopup.js @@ -55,8 +55,6 @@ function showPostPreview(e) { cln.innerHTML = 'Загрузка...'; - var found = false; - //если пост найден в дереве. if($('div[id='+pNum+']').length > 0) { var postdata = $('div[id='+pNum+']').html(); @@ -66,34 +64,29 @@ function showPostPreview(e) { //make preview mkPreview(cln, postdata); - - found = true; } //ajax api -// else { -// $.getJSON(mayuri_cfg['board_url']+'api/single/'+pNum) -// .success(function(data) { -// //post templates -// var postdata = makeAjaxPost(data).html(); -// -// //TODO: временно -// //funcInit(postdata); -// -// //make preview -// mkPreview(cln, postdata); -// -// })//if error -// .error(function() { -// cln.innerHTML = 'Пост не найден.'; -// }); -// } + else { + $.ajax({ + url: '/api/post/' + pNum + }) + .success(function(data) { + // TODO get a json, not post itself + var postdata = $(data).html(); + + //make preview + mkPreview(cln, postdata); + + }) + .error(function() { + cln.innerHTML = 'Пост не найден.'; + }); + } $del(doc.getElementById(cln.id)); - if (found) { - //add preview - $('body').append(cln); - } + //add preview + $('body').append(cln); } function delPostPreview(e) { diff --git a/boards/urls.py b/boards/urls.py --- a/boards/urls.py +++ b/boards/urls.py @@ -52,5 +52,5 @@ urlpatterns = patterns('', url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), # API - url(r'^get_post/(?P\w+)/$', views.get_post, name="get_post"), + url(r'^api/post/(?P\w+)/$', views.get_post, name="get_post"), )