WinterCMS PHP renderPartial не работает после запроса jQueryJquery

Программирование на jquery
Ответить
Anonymous
 WinterCMS PHP renderPartial не работает после запроса jQuery

Сообщение Anonymous »

В плагине default.htm

Код: Выделить всё

{% partial 'companies' %}


jQuery( document ).ready(function() {
jQuery('body').on('click', '#create_new', function(){
jQuery('form').request('onAllocate');
});

jQuery( "#tabs" ).tabs() ;

jQuery('body').on('click', '.block_user', function(){
if(confirm('Are you sure you want to block this user?'))
{
var alt = jQuery(this).attr("alt");
jQuery('form').request('onUserBlock', {data: {alt: alt},});
}
});

});


company.htm частично

Код: Выделить всё


Name
Email address



{% for id, row in companies %}

{{ row.name }}
{{ row.email }}

[url=javascript:;][Block][/url]



{% endfor %}

плагин Account.php

Код: Выделить всё

public function prepareVars()
{
$this->page['user'] = $this->user();
$this->page['canRegister'] = $this->canRegister();
$this->page['loginAttribute'] = $this->loginAttribute();
$this->page['loginAttributeLabel'] = $this->loginAttributeLabel();
$this->page['updateRequiresPassword'] = $this->updateRequiresPassword();
$this->page['rememberLoginMode'] = $this->rememberLoginMode();

#Log::info(json_encode($this->post_id));
if($this->page->id == 'users' && $this->user())
{
$this->onCompanies();
}
}

public function onCompanies()
{
$usr = Auth::User()->getAttributes();

$list = Array();

$all = Db::select('select * from users_allocation where slave_id = ? and blocked < 1', [$usr['id']]);

if (count($all) > 0) {
foreach ($all as $a) {
$company = Db::select('select * from users where id = ?', [$a->owner_id]);
if (count($company) > 0) {
foreach ($company as $cp) {
$cid = md5($cp->id);

$list[$cid]['user_id'] = md5($a->owner_id);
$list[$cid]['name'] = $cp->name;
$list[$cid]['email'] = $cp->email;
}
}
}
}

$this->page['companies'] = $list;
return [
'#tabs-1' => $this->renderPartial('companies')
];
}
jQuery('form').request('onUserBlock', {data: {alt: alt},}); вызывает функцию onUserBlock в Account.php

Код: Выделить всё

public function onUserBlock()
{
$data = post();
$id = $data['alt'];
$usr = Auth::User()->getAttributes();

$company = Db::select('select * from users_allocation where  md5(owner_id) = ? and slave_id = ? and blocked = 1', [$id, $usr['id']]);

if (count($company) > 0) {
Flash::error('This company already blocked.');
return false;
}
else
{
Db::update('update users_allocation set blocked = 1 where md5(owner_id) = ? and slave_id = ?', [$id, $usr['id']]);

$this->onCompanies();

Flash::success(Lang::get(/**/'Company successfully blocked and will not able to send you invitation.'));
}
}
Проблема в том, что когда prepreVars вызывает onCompanies при загрузке страницы, код отображает html, но когда onCompanies вызывается из onUserBlock, код не выполняет повторную визуализацию html.Есть идеи, почему?
Я пытался поместить $this->onCompanies(); до и после Flash::успех, но безуспешно.

Подробнее здесь: https://stackoverflow.com/questions/793 ... ry-request
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»