Can I render & use a "filepicker" inside the response of an Ajax call??

Can I render & use a "filepicker" inside the response of an Ajax call??

Daniel Gonzalez Lareo -
回帖数:2

Hi people!!

I've problems to show a filepicker in a form that is processed as a Ajax response.

When you load the page a js function, print_experiment(), is called. The response of this function depends of sevaral parameters. And one of the cases is a moodle_quickform that maybe contains a filepicker. All the other form elements works correctly but the filepicker stay blocked (with the loading circle). I know that filepicker uses a lot of Ajax. But there is a solution to use it in that way??

Someone can explain me (or point me the correct way) how can I solve this ??

 

Thanks a lot!!

 

PD: The version of moodle that I'm working with is 2.3

回复Daniel Gonzalez Lareo

Re: Can I render & use a "filepicker" inside the response of an Ajax call??

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像

ForumNG does this. Well, it achieves this effect: https://github.com/moodleou/moodle-mod_forumng/ Sorry, I don't know which the key bits of code are.

回复Tim Hunt

Re: Can I render & use a "filepicker" inside the response of an Ajax call??

sam marshall -
Core developers的头像 Peer reviewers的头像 Plugin developers的头像

In summary, this is a nightmare.

In slightly less summary, if you create the necessary html as normal, then you will need to manually call the javascript init function that usually gets called for filepicker. ForumNG does it by having a 'template' of what the html/script should be then replacing certain variables in that template with the itemid, context or whatever it has in there (I forget).

--sam