Гость
03 Дек 2012 18:06

I'm the old user of your cck software, so i used to write a couple of fields. I remember you were using xajax and there was a nice possibility to declare and call custom plugin (field) functions.

In Cobalt i don't see the posibility to do it. Basicly i have to write php code in "ajax.php" file if i want to call it from js. Maybe i am wrong and there is actually a nice way to call my plugin functions from js without modifying core files?

Последние изменения: 02 Март 2014


Sergey
Total posts: 13,748
03 Дек 2012 23:55

If you are talking about ability to call AJAX metods in the field here is the main principle.

JavaScript

var req = new Request.JSON({

url: URL_ROOT + "index.php?option=com_cobalt&task=ajax.field_call&no_html=1",

method:"post",

autoCancel:true,

data:{

    field_id: id,

    func: "_changeStatus",

    field: "status",

    record_id: rid, 

},

onComplete: function(json) {

    if(!json.success)

    {

        alert(json.error);

        return;

    }

    console.log(json.result);

}

}).send();

Important here to know that data:{} contain required data. filed is the type of the field. I mean name of the field folder. And you can pass and "func" name.

Now you only need to create function in the field.

public function _changeStatus($post)

{

$record_id = $post['record_id'];

return 1;

}

Whatever you return become json.result in javascript onComplete()


Sergey
Total posts: 13,748
04 Дек 2012 00:08

Гость
15 Дек 2012 05:52

Sorry, it took 1 week to respond :)

Just wanted to say that the article you posted was the thing i needed.

Thanks!


Sergey
Total posts: 13,748
15 Дек 2012 06:39

Hope we all will see result of your work very soon :)

Работает на Cobalt