pjax

PJAX listen to pjax:end event with standard js

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So github uses "defunkt's" PJAX module ( https://github.com/defunkt/jquery-pjax#events ), and I'm making a firefox addon that needs to listen to the event pjax:end So far I can do it with jquery like this: $(document).on('pjax:end', function (t) { console.log('pjax:end'); }) however how do I do this with standard javascript functions? document.addEventListener('pjax:end',function(){ console.log('ya'); }, true); does not work. for those who know firefox-addons this code code does not work: gBrowser.contentWindow.wrappedJSObject['$'](gBrowser

history.pushState - not working?

不羁岁月 提交于 2019-12-03 01:57:28
I want to change html without reload. I do it like: $('#left_menu_item').click(function(e) { if (!!(window.history && history.pushState)) { e.preventDefault(); history.pushState(null, null, newUrl); } }); It works correctly. But if I want to go back with "Back" button - browser change url on previous, but it not reload page. Why? this behaviour is expected and is in accordance with the specifications of manipulating the history stack. this is a relatively complex problem to explain. but in short think of it as this: any history entry the user pushes on the history stack (using pushState etc)

yii2 how to use pjax when hyperlink is not in pjax

♀尐吖头ヾ 提交于 2019-12-02 01:01:58
问题 To use pjax in yii2, just like: <?php Pjax::begin(); ?> <?= Html::a("Refresh", ['site/index'], ['class' => 'btn btn-lg btn-primary']);?> <h1>Current time: <?= $time ?></h1> <?php Pjax::end(); ?> but what if the hyperlink is not in the <?php Pjax::begin(); ?> <?php Pjax::end(); ?> , just like: <nav> <a href="">Click to refresh</a> </nav> <?php Pjax::begin(); ?> <h1>Current time: <?= $time ?></h1> <?php Pjax::end(); ?> 回答1: PJAX has timeout option. If PJAX not obtain AJAX response during this

Yii2 Pjax and ActiveForm beforeSubmit not working after reload?

喜夏-厌秋 提交于 2019-12-01 23:44:43
问题 I am creating a loading indicator on my submit button and attaching the "start" procedure to the beforeSubmit event using the registerJs function. It works properly the first time, but after the Pjax container is reloaded, the event won't fire when the form is submitted again. I am enclosing the entire view file in the Pjax container so that the flash messages are properly displayed. Here is the main.php layout file snippet: <?php Pjax::begin([ 'id' => 'pjax-container', 'enablePushState' =>

Yii2 Pjax and ActiveForm beforeSubmit not working after reload?

元气小坏坏 提交于 2019-12-01 20:25:25
I am creating a loading indicator on my submit button and attaching the "start" procedure to the beforeSubmit event using the registerJs function. It works properly the first time, but after the Pjax container is reloaded, the event won't fire when the form is submitted again. I am enclosing the entire view file in the Pjax container so that the flash messages are properly displayed. Here is the main.php layout file snippet: <?php Pjax::begin([ 'id' => 'pjax-container', 'enablePushState' => false, ]); ?> <?= Alert::widget(); ?> <?= $content; ?> <?php Pjax::end(); ?> And here is the registerJs

How to update widget with pjax in modal window in yii2

人走茶凉 提交于 2019-11-30 22:18:52
I have two ActiveForms in a modal window and after submitting first form, I need to update second one and stay in modal. As I understand pjax can handle that, but can't get it to work properly. In _form.php I have ActiveForm with widget wich should be updated: <?php $form = ActiveForm::begin([ 'id'=>'form', 'enableAjaxValidation'=>true, ]); ?> <?= Html::activeHiddenInput($riskModel, 'id', ['value' => $riskModel->id]) ?> <?php Pjax::begin([ 'id' => 'solutionItems', ]) ?> //need to update this widget <?= $form->field($riskModel, 'solutions_order')->widget(SortableInput::classname(), [ 'items' =>

How to make github style page transitions by pjax

耗尽温柔 提交于 2019-11-30 20:58:44
Once a time, I read an article said that github page transition is made by pjax, I checked jquery-pjax project. I think I have close to the answer, it must be something related with event pjax:start and pjax:end , but I still can't get it works, so I try to get some help here. $('a.pjax').pjax('#main'); $('#main').bind('pjax:start', function(){$('#main').slideUp()}) .bind('pjax:end'), function(){$('#main').slideDown()}); But it has no effects Github use HTML5 features for the page transitions. That includes the new JS History API and CSS3 transitions. No jQuery involved except for standard

How to make github style page transitions by pjax

 ̄綄美尐妖づ 提交于 2019-11-30 17:03:31
问题 Once a time, I read an article said that github page transition is made by pjax, I checked jquery-pjax project. I think I have close to the answer, it must be something related with event pjax:start and pjax:end , but I still can't get it works, so I try to get some help here. $('a.pjax').pjax('#main'); $('#main').bind('pjax:start', function(){$('#main').slideUp()}) .bind('pjax:end'), function(){$('#main').slideDown()}); But it has no effects 回答1: Github use HTML5 features for the page

jquery pjax request sending twice

元气小坏坏 提交于 2019-11-30 12:30:00
I have a rails app and I keep getting a weird behavior with pjax requests. When I look into my development logs I could see that two requests are being made. The first request is pjax and the next one is not. As a result the page still reloads. I appreciate if anyone could help me with this. The JQuery pjax plugin has a default error handler, that will simply reload the target page. This error handler gets called when the timeout has passed, which pjax sets very low. As a result, if your request takes too long, you will see two identical requests. The pjax request (probably with the _pjax

Yii2 Pjax not working

拥有回忆 提交于 2019-11-30 04:14:29
I want to refresh the gridview using Pjax but somehow it is not working. Here is the code: _search.php <?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\widgets\Pjax; $this->registerJs(" $('#btnAjaxSearch').click(function(){ $.ajax({ type: 'get', data: $('.bank-search form').serializeArray(), success: function (data) { $.pjax.reload({container:\"#bank\"}); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert('error'); } }); return false; }); ", \yii\web\View::POS_END, 'bank-search'); ?> <div class="bank-search"> <?php Pjax::begin(['id' => 'bank-form']); ?> <?php