Welcome Guest, Not a member yet? Register   Sign In
Cjax 5.5 (Latest 5.8 now)
#1

[eluser]Ajaxboy[/eluser]
Cjax - Ajax Framework for CodeIgniter - 5.5 Now Available



Download
https://sourceforge.net/projects/cjax/fi...deIgnater/


Demos:
http://cjax.sourceforge.net/examples/


Folk:
https://github.com/ajaxboy/cjax

Version 5.5 of Cjax is now available for download. This much awaited release has support for php 5.4.

#2

[eluser]Unknown[/eluser]
Hello Ajaxboy,

Do You know how to configure the Cjax 5.5 with i18n ( http://jeromejaglale.com/doc/php/codeigniter_i18n ) language library ?
Because i get the 404 error all the time.

This is my .htaccess file

Code:
RewriteEngine on
RewriteCond $1 !^([a-zA-z0-9/])
RewriteRule ^(.*)$ index.php [L]
RewriteRule  ^/?ajax/(.*)$ ajax.php?$1 [NC,QSA,L]
RewriteCond $1 !^(index.php|ajax.php|ajaxfw.php|system|uploads|uploadify|images|cjax)
RewriteRule ^(.*)$ index.php/$1 [L]

#3

[eluser]Ajaxboy[/eluser]
There hasn't been any testing from my part on library i18n, so compatibility is not guaranteed.
#4

[eluser]Needle[/eluser]
I'm wondering how to add a jQuery function as part of the CJAX response. So for example, in jQuery you can have something like this:

Code:
$.ajax({

  type: "POST",
  url: "/",
  data: $(".form").serialize(),
  dataType: "html",

         success: function(data) {
                 var jqObj = $(data);
                 $("#id").empty().append(jqObj).slideDown("slow");
                }

});

Using CJAX I'm able to successfully get an AJAX response and stick that data in a div, but I'm stuck when it comes to triggering a custom jQuery function (such as the slideDown() function in this example. Where might I add this in CJAX?
#5

[eluser]Ajaxboy[/eluser]
Cjax returns a JSON Object if your return an array in your response controller.

In jquery you have to request data type JSON..


Code:
dataType: "json"
#6

[eluser]Needle[/eluser]
Thanks for the reply. I think the JSON object makes sense. But I'm still not sure how to trigger a jQuery event from the CJAX response.

I know CJAX provides the built-in message methods ($ajax->message(), $ajax->info(), etc), but instead of the standard overlay for the message I'm trying to use a little jQuery slideDown() div. I'm just not sure how to trigger that slideDown() event with CJAX. It looks like the best way is probably to create a little custom js function as described here and then call that custom function alongside my regular CJAX functions.

Does that make sense or is there a simpler way that I'm missing?
#7

[eluser]Ajaxboy[/eluser]
Technically this is untested, and no guarantee it would work but you could try something like this:

$ajax->jQuery('slideDown', "div_id","{1,2,3}");.. etc


Cjax allows you to access objects on the page including the Jquery object, the only thing we need to find out is how to access them. Generally parameters are passed down to the JavaScript Object/Function.

If that doesn't work let me know and I'll do a little testing as soon as time allows.
#8

[eluser]Needle[/eluser]
Thanks Ajaxboy. I tried your example but could not trigger the jQuery.

In my test I sent the ajax response to a div called "msgs" like so:

Code:
$ajax->msgs = "Your feedback has been received.";
$ajax->jQuery('slideDown', "msgs", "{300}");

The msgs div was populated successfully but the jQuery slideDown event never happens. Instead it gives this alert:

#process unabled to load function#1: _fn(); undefined
#9

[eluser]Ajaxboy[/eluser]
The error indicates that is not the way how you'd access that object, so further testing is needed on accessing jquery object.

In the mean time alternatively, although I an not a fan of eval, you can also use eval:

//eg
Code:
$ajax->eval("$('#msgs').slideDown();");
#10

[eluser]Ajaxboy[/eluser]
You could also use a wrapper. Eg:

Code:
//js code
function slider_wrapper() {
//your jquery code here

}


Code:
$ajax->slider_wrapper();




Theme © iAndrew 2016 - Forum software by © MyBB