How to add jquery in a plug-in stored at moodle/local/

How to add jquery in a plug-in stored at moodle/local/

by Mari Cruz García -
Number of replies: 3

Hello,

Sorry if my question is stupid but I cannot understand the information in the documentation: 


I have created a php file as a local plug-in at /moodle/local/student_progression_report

 

Which displays certain information about the student.

 

I would like to create an expandible content container so that certain sections of the student's information are collapsed by default, but they can be expanded. I found the code attach in W3 Schools.

 

I am not sure of how I have to add jquery from the information in Moodle.org:

http://docs.moodle.org/dev/jQuery#jQuery_UI_in_add-on_activity_module

 

Do I need to add these lines at the beginning of the php file?

 

$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('ui');
$PAGE->requires->jquery_plugin('ui-css');

Do I need to place physical the jquery file in any folder of Moodle?

 

Thank you very much for your advice.

 

Mari Cruz

__________________________________________________________________

 

 

</head>

<body>

 

<div data-role="page" id="pageone">

  <div data-role="header">

    <h1>Expanded Collapsible Blocks</h1>

  </div>

 

  <div data-role="main" class="ui-content">

    <div data-role="collapsible" data-collapsed="false">

      <h1>Click me - I'm collapsible!</h1>

      <p>I'm now expanded by default.</p>

    </div>

  </div>

 

 

</body>

Average of ratings: -
In reply to Mari Cruz García

Re: How to add jquery in a plug-in stored at moodle/local/

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

You don't actually need to use jquery for that. See the print_collapsible_region() function in lib/weblib.php

In reply to Mari Cruz García

Re: How to add jquery in a plug-in stored at moodle/local/

by Frankie Kam -
Picture of Plugin developers

Hi Aaricia

You can check out slides 132 and 133 of my iMoot2014 presentation, if it's any help to you.
http://www.slideshare.net/kamboonseng/frankie-kam-soup-up-i-moot-quiz-with-javascript-css-jquery-15th-may-2014

Cheers
Frankie Kam

In reply to Frankie Kam

Re: How to add jquery in a plug-in stored at moodle/local/

by Mari Cruz García -

Thanks to both for answering. I will have a look to your suggestions and come back to you