-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pjax initialize does not work on empty grids #107
Comments
Solved this problem as described in issue #30 at the bottom. I added to the page: 'customer_label', 'class' => 'kartik\grid\EditableColumn', 'name' => 'hidden', 'inputType'=>\kartik\editable\Editable::INPUT_TEXT, 'containerOptions'=>['style'=>'display:none'], 'pjaxContainerId'=>'none' ]); ?>Is there a nicer way of doing this? |
It depends on how you are writing your app specific code and use case. If you use the default EditableColumn with this extension it takes care of the initialization in the container. You can cross check the demos page - you can try to filter the grid with a vague value - and the grid will return no records - but the editable columns initialize automatically. If you are rendering your own custom editables content in a pjax container then you need to control their re-init for various cases... the pjax based reinitialization is just provided as an accelerated method to re-init but it may not cover your every use case and you need to control that manually (setting pjaxContainerId to none is not needed - to disable pjax reinit you must ensure it is NOT SET to your pjax container's identifier). |
Hi Kartik. Great job! I think I'm getting the same issue. I notice that editable.css and editable.js are not been loaded. Sorry for my bad English. |
I'm using a gridview with an editable column in combination with another form to add a new db row using pjax. The form and the gridview are in separate pjax containers.
Everything works fine when there is at least one row in the gridview when the page is loaded. If the grid is empty, then the editable column will not initialize properly on pjax reloads.
I get "Uncaught TypeError: jQuery(...).editable is not a function" when the gridview is reloaded.
Here is the code for the affected view:
registerJs( '$("document").ready(function(){ $("#new_sample").on("pjax:end", function() { $.pjax.reload({container:"#samples"}); }); });' ); ?> registerJs( '$("#samples").on("click", ".ajaxDelete", function(e){ e.preventDefault(); var deleteUrl = $(this).attr("delete-url"); bootbox.confirm("Are you sure you want to delete this sample?", function (result) { if (result) { $.ajax({ url: deleteUrl, type: "post", error: function (xhr, status, error) { alert("There was an error with your request." + xhr.responseText); } }).done(function (data) { $.pjax.reload({container:"#samples"}); }); } } ); });' ); ?> 'new_sample']); $form = ActiveForm::begin(['options' => ['data-pjax' => true], 'type' => ActiveForm::TYPE_INLINE, 'formConfig'=>['labelspan' => 0, 'deviceSize'=>ActiveForm::SIZE_MEDIUM]]); ?>The text was updated successfully, but these errors were encountered: