This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

emzero439
emzero439

I'm modifying the OctoCase plugin and I'm wanting to add some ajax functionality to it.

I've added an AJAX handler to the components\Items.php

public function onPortfolioItemClick()
{
    $this['result'] = "This is the result";
}

I've added the Items component to a page as following:

{% component 'octocaseItems' %}

Below I added a little test using the AJAX Data attributes API:

<form data-request="octocaseItems::onPortfolioItemClick" data-request-update="ajaxResult: '#result'">
    <input type="submit" value="Calculate">
</form>
<div id="#result"></div>

ajaxResult partial is as simple as This is the result: {{ result }}

But when I click the submit button, I see the ajax loading bar on top but then a dialog appears saying: Cannot use object of type \OctoDevel\OctoCase\Components\Items as array

What am I missing?

haakonht6707
haakonht6707

Does anyone ever answer any support threads here?

Jasson_10861
Jasson_10861

maybe you should try to convert it to array?

$items = Items::all(); return $items->toArray();

http://laravel.com/docs/4.2/eloquent#converting-to-arrays-or-json

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.