Open mbilkin opened 6 years ago
How do you create/open the modal window? You could check that just one modal window should be open. If you see in browser console modal window duplicates, when fire the action to open the modal window destroy the previouses, so the form should be submitted just one time.
On the page there is a GridView with its pjax, it has links in the lines. Links are not one but several.
<a href="{url}" data-target="#clob-data" data-toggle="modal" data-remote="true"><span class="glyphicon glyphicon-duplicate" title="" data-toggle="tooltip" data-original-title="Дублировать"></span></a>
When you click link, the modal window opens. Content is loaded remotely (data-remote="true"). The code for the remote script was presented above. In it, the form sends data to its pjax. In this case, the event hung on opening the first modal window is saved (not destroyed) ... and when the next modal window is opened, it will also be executed. Because the next code will be executed each time a window is opened.
jQuery(document).pjax("#new_note a", {"push":false,"replace":false,"timeout":1000,"scrollTo":false,"container":"#new_note"});
jQuery(document).on("submit", "#new_note form[data-pjax]", function (event) {jQuery.pjax.submit(event, {"push":false,"replace":false,"timeout":1000,"scrollTo":false,"container":"#new_note"});});
is it fixed?
No.
Dobles peticiones con pjax lo solucionaba concatenando uniqid de PHP:
'id' => 'new_note' . uniqid()
@fmunoz88 solution is good. If you want to call some manual pjax event just set the "class" and call them by using className
Is it fixed ?
No, it's not. When something is fixed, issue is closed.
$('#pjax-name').on('pjax:end', function(e) {
e.preventDefault();
$.pjax.reload({timeout: false, container:'#grid-name'});
});
// Fix The Problems of Universe
$(document).on('submit', '#form-name', function(e) {
e.preventDefault();
return false;
});
after try several many times, i found the best solutions, greet thanks.
Nowadays the best, fast and scalable solution for these things is using Vue.js. React.js or similar.
They are usable also for just one single page / view, simply including js references.
I did it to solve:
Pjax::begin( [ 'id' => uniqid('pjax_'), 'clientOptions' => [ 'container' => '.modal-content' ] ] );
Now it works fine..
#11761 pigochu write 16 Jun 2016
I install yii2-pjax 2.0.7.1 I use gridView and action on row, wich inicialize modal content (pjax+form). After submit modal form gridView reloaded. view for modal window:
Yii generated js:
But if I open modal N times, it will submit N times. I look at methods handleSubmit and handleClick and I see that one (handleClick) is fixed and the other does not (handleSubmit). In the handleSubmit method, there are no following lines:
Why?
Additional info