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

guino199623086
guino199623086

I have a page with a AJAX searcher, i want to load default items like press search with empty text and view all items.

This is my form:

<form id="form1" data-request="onTest" data-request-error="alert('No ha introducido la busqueda correctamente.')" data-request-update="project: '#results'">

<!-- Inputs -->

<label for="title">Filtro basico: </label>

<input name="title">

<!-- Submit -->

<button id="search" class="btn-success" type="submit">Buscar</button>

This is my onTest() function

function onTest(){

    $this['result'] = $title = input('title');

    $title = "%".str_replace(" ","%",$title)."%";

    $projects = Project::where('is_valid', '=', 1)->where('title','like',$title)->get();

    $this['projects'] = $projects;

}

This function works perfectly, but if i put

$projects = Project::where('is_valid', '=', 1)->orderBy('limit_date', 'desc')->limit(6)->get();

$this['projects'] = $projects;

in onStart() always displays the default items, first display searched items and concatenates them with defaults, is there any way to load default items? on first page load? Do you need more information?

Last updated

1-1 of 1

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