Advanced modules and javascript confusion
When I look at the cronjobs module I get really confused.
As far as I can tell there is somewhere a JS script that makes a button with an id of action reload the controllor. Is that correct? This script must also be ajax request, because in the controller the values are retrieved with a POST?
Where can I find this javascript, because in the assets of the cronjob folder there is only JS to delete a row. And more important is there any documentation about this?
Another question: what version of jqeury does the admin use? It seems like it is an old version because it does not recognise the .on method yet but only the older .click event. How can I change the Jquery file to the most recent?
I really like FUEL cms and I think it is amazing that you put this opensource, but I really hope that the documentation will get better. For some parts it is already quite good. But for example advanced modules are really hard to grasp without the available documentation. (could also be my lack of knowledge
)
Comments
The input #action is on line #61 in the cronjobs view:
<?=$this->form->hidden('action', $action)?>
When you click the delete icon to the right of the action it's value is set by the js I think you've seen the CronjobsController.js file and the form is submitted.
jQuery version is v1.5.1. Replace it in fuel/modules/fuel/assets/js/jquery/jquery.js
You are right that it is a normal POST. I shoud have seen that. About the Jquery file I thought it was something else but that is probably because it is minified?
I understand how the value in the hidden field is used to either delete or add a crontask. However I still don't how the a href submits the form.
in CronjobsController.js the init methods calls three functions:
init : function(initObj){ this._notifications(); this._submit(); this._super(initObj); }
Does one of this do the job? And does anyone know where I could find them among all the .js files in the 'modules/fuel/assets/' folder.
I ask this because I am really interested how this is done. Because I like the way it works.
The init function there is running/bringing into scope the BaseFuelController methods as defined in /modules/fuel/assests/js/fuel/controller/BaseFuelController.js
To answer your question though, the form is being submitted with the plain old .submit() on those button clicks.
This line:
$('#form').submit();
Just to be sure we're looking at the same thing, I see this:
var CronjobsController = { init : function(initObj){ this._notifications(); this._submit(); this._super(initObj); }, cronjobs : function(){ $('.fillin').fillin(); $('#remove').click(function(e){ $('#action').val('remove'); $('#form').submit(); // here return false; }); $('.ico_remove_line').click(function(e){ $(this).parent().find('input').val(''); $('#form').submit(); // and here return false; }); } }; jqx.extendController(CronjobsController);
$("#submit").click(function(e) ............etc
In the init funcion above it has this._submit which is defined in the BaseFuelController file, it's this code:
_submit : function(){ $('#submit').click(function(){ $('#form').submit(); return false; }); },
Theres the click function you were asking about.