General developer forum

 
 
Picture of Erica Underwound
integrating moolde-local_jquery in view
 

hello all,

i am just starting to work with moodle and am kind of stuck here. after starting to write my first module using a model/view/controller approach with SODA (http://tech.solin.eu/doku.php?id=moodle:using_soda_to_create_new_moodle_modules) i tried to use jquery and encountered some problems.
then i found the moodle-local_jquery plugin which i installed sucessfully. what i wasn't able to find is a documentation on how to include it in my view.html code.

thankful for any suggestions!

 
Average of ratings: -
Andrew Normore
Re: integrating moolde-local_jquery in view
 

I just included it in my theme.

 
Average of ratings: -
Picture of Erica Underwound
Re: integrating moolde-local_jquery in view
 

Thanks for this. But I was hoping for a more presice answer - maybe a line of code.

Ideally it shouldn't be in the Theme but within my module. So if the Module is transfered to another Moodle system the hadling still stays simple.

Any ideas on this?

 
Average of ratings: -
Picture of Céline Perves
Re: integrating moolde-local_jquery in view
 

Hello,

where did you find such a plugin?

I put my jquery code threw a local plugin too and call jquery thanks to page object :

if you have a path for your js : $PAGE->requires->js($_jspath.'jquery.js',true);

I note that you have to execute that line before executing echo $OUTPUT->header(); otherwise your javascript file will not be called

 

Hope that it will help you

 

 
Average of ratings: -
Andrew Normore
Re: integrating moolde-local_jquery in view
 

Local plugin seems like the best way to go. 

You could create /local/jquery/index.php 

Then as Celine said, $PAGE->requires->js($_jspath.'jquery.js',true);

 
Average of ratings: -
Picture of Erica Underwound
Re: integrating moolde-local_jquery in view
 

Hi Celine,

this is the link to the plugin: https://github.com/bumoodle/moodle-local_jquery

Thank you for your tip. Unfortunalty I am still not sure on how to apply this on the whole plugin, consisting of styles and scripts ...

 

 

 

 
Average of ratings: -
Picture of Céline Perves
Re: integrating moolde-local_jquery in view
 

Thank you for the git link

 
Average of ratings: -
Onno
Re: integrating moolde-local_jquery in view
 

Hi Erica,

Soda author here (sorry to respond so late, didn't see your message before). You can always include a javascript library through your theme. But if you only want to include jquery in the views of your Soda based module, you can use the views/template.html file. (The template is documented on tech.solin.eu.)

Inside your template.html view, just include jquery like this:

<script type="text/javascript" src="<?php echo $CFG->wwwroot ?>/mod/yourmod/a-jquery-version.js"></script>

Hope this helps you out!

By the way, I'm very curious what you're using Soda for. Could you tell us a little more about your module?

 

Bye!

Onno

 
Average of ratings: -