I've got a page (id=7) which shows the output of a migxLoopCollection call (paginated by getPage and filtered by a &where parameter). (The items of the collection are articles of a catalogue.)
The visitor of the page is able to put individual items of the collection on a "memory list" which will be saved as a string in the session as $_SESSION['memids']. (This is done in a snippet "memids_to_session").
A typical value of this string would be "+109+101+123+111".
To add a single item to this list, there is a form with just a button "add-to-list" in the &tpl chunk of the collection. If f.i. in the item having id=107 this button is clicked, the string value above is changed to "+109+101+123+111+107". Submitting the form loads another page (id=35) showing the list of already chosen items (after fetching the value of $_SESSION['memids']).
This all works fine like intended.
Now I wanted to give the visitor the possibility to set all of the items of the collection on page (7) to the memory list by one click on the submit button of a form on this page. So I use the above mentioned snippet "memids_to_session" with a parameter &memids the value of which I get by the same migxLoopCollection call as for the page itself.
I tried various ways:
First try:
<form id="add-all-to-list" action="[[~35]]" method="post">
<input id="memids" name="memids"
value= "[[!memids_to_session? &memids=`
[[!migxLoopCollection?
&packageName=`foo`
&classname=`foo`
&tpl=`@CODE:+[[+id]]`
&where=`[[!prepareWhere]]`
]]
`]]" type="hidden">
<input name="all-to-list" value="Alle auf die Merkliste" class="submit" type="submit" />
</form>
in combination with this jQuery code:
$('#add-all-to-list').submit(function() {
$.ajax({
type : 'GET',
url : '[[~35]]',
data : $('#add-all-to-list').serialize(),
success : function() {
}
});
};
Second try:
<form id="add-all-to-list" action="[[~35]]" method="post">
<input name="all-to-list" value="Alle auf die Merkliste" class="submit" type="submit" />
</form>
in combination with this jQuery code:
$('#add-all-to-list').submit(function() {
$.ajax({
type : 'GET',
url : '[[~35]]',
data : [[!memids_to_session? &memids=`
[[!migxLoopCollection?
&packageName=`foo`
&classname=`foo`
&tpl=`@CODE:+[[+id]]`
&where=`[[!prepareWhere]]`
]]
`]],
success : function() {
}
});
};
With both variants I get the mentioned problem: All the items are added to the list immediatley, after the first load of page (7).