Fullcalendar migrate from 3.x to 4.x extraParams doesn't manipulate multiple input as array

霸气de小男生 提交于 2019-12-11 06:34:15

问题


I'm trying to migrate from fullcalendar 3.x to 4.x

<select id="ids" name="ids[]" class="form-control" multiple>
 <option value="1" selected> Option 1</option>
 <option value="2"> Option 2</option>
 <option value="3"> Option 3</option>
</select>

<button type="button" id="btn-filter">Apply</button>

In 3.x version the data parameter inside events are correctly managed as array:

This is my FIREFOX CONSOLE:

array_ids[]:
    0: 1
    1: 2
start:  2019-06-01T00:00:00
end:    2019-07-01T00:00:00

Piece of code:

  events: {
        url: './get-events.php',
        cache: false,
        type: 'POST',
        data: function() { // a function that returns an object
          return {
            array_ids: $("#ids").val()
           };
        }
        error: function () {
            alert('there was an error while fetching events!');
        },
    },

Now after converting into 4.x with this code:

         events: {
            url: './get-events.php',
            cache: false,
            method: 'POST',      <--- type -> method
            extraParams: function() { 
              return {
                array_ids: $("#ids").val()
              };
            }
        },

my FIREFOX CONSOLE show:

array_ids: 1,2             //as string

See attachment ( array_ids is renamed in this example but the logic is the same)

来源:https://stackoverflow.com/questions/56987425/fullcalendar-migrate-from-3-x-to-4-x-extraparams-doesnt-manipulate-multiple-inp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!