Welcome Guest, Not a member yet? Register   Sign In
How to using Ajax -mootools in CI ?
#1

[eluser]An Phu[/eluser]
when searching i found example on "http://davidwalsh.name/dw-content/mootools-record-delete.php"
so i can't understand : these code below
"01.window.addEvent('domready',function() {
02. $$('a.delete').each(function(el) {
03. el.addEvent('click',function(e) {
04. e.stop();
05. var parent = el.getParent('div');
06. var request = new Request({
07. url: 'mootools-record-delete.php',
08. link: 'chain',
09. method: 'get',
10. data: {
11. 'delete': parent.get('id').replace('record-',''),
12. ajax: 1
13. },
14. onRequest: function() {
15. new Fx.Tween(parent,{
16. duration:300
17. }).start('background-color', '#fb6c6c');
18. },
19. onSuccess: function() {
20. new Fx.Slide(parent,{
21. duration:300,
22. onComplete: function() {
23. parent.dispose();
24. }
25. }).slideOut();
26. }
27. }).send();
28. });
29. });
30.});
"
So Someone can explain to me how it work and send to me some document about using ajax-mootools in CI ,Basic Event and thank you so much
#2

[eluser]Thorpe Obazee[/eluser]
I suggest you go to the Mootools Google Group.
#3

[eluser]asylmottaket[/eluser]
It's probably not much for an answer, but using Ajax libraries/frameworks and javascript in general is like using it with any other PHP code and HTML markup, PHP-framework or not.

Ex. instead of making a "Ajax" GET request to some single PHP file, you direct the request to some CI method handeling your request based on given parameters sent in the "Ajax"-request.

Checked into jQuery? I found it easier to learn.
#4

[eluser]xwero[/eluser]
Ajax calls are almost the same in all the javascript library. The unmodified example will produce mootools-record-delete.php?delete=1&ajax=1 to connect to the severside code.

If you want to make it work in CI you have two options.

Only changing the url. This means the uri_protocol setting in the config.php file is best set to path_info/orig_path_info/request_uri which makes CI blind for the query string as a part of the url. Because CI cleans the GET global you can restore it in the method
Code:
parse_str($_SERVER['QUERY_STRING'],$_GET);

The second option is to remove the data part and add the parameters as segments of the url
Code:
url: ‘controller/method/’+ parent.get(‘id’).replace(‘record-’,’‘) + '/1',
This means you don't have to change the settings you already have or restore the GET global.
#5

[eluser]An Phu[/eluser]
Thanks for help ,i has made a project CI-Ajax and it work ,so i want research about mootools-ajax when using in CI .




Theme © iAndrew 2016 - Forum software by © MyBB