I created a component inside my plugin directory and in default.htm i put my form html and include my component in my partial. But when i when i submit form i'm getting "AjaxHandler Component:onSend was not found"
default.htm
<div class="filter-holder">
<div class="container">
<div class="row">
<form name="contact-form" data-request="{{ __SELF__ }}::onSend" data-request-success="alert('Message Sent')">
<div class="col-md-5">
<input type="text" name="agent" class="form-control">
</div>
<div class="col-md-2">
<select class="form-control" id="services" name="services[]">
{% for client in records %}
<option value="{{ client.service }}">{{ client.service }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<select class="form-control" id="search" name="area[]">
{% for client in records %}
<option value="{{ client.area }}">{{ client.area }} Miles</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<input type="submit" value="Agents" class="red-btn btn btn-default">
<a class="location-view" href="#">location</a></div>
</form>
ComponentClass.php
class MarkerData extends ComponentBase {
public function componentDetails() {
return [
'name' => 'Marker Data',
'description' => 'List of marker data'
];
}
public function onSend()
{
$data = post();
print_r($data);die;
}}
and In my partial file i included component
{% component "MarkerData" %}
Partial Code:
description = "A quick way to reference testimonials in the theme."
[viewBag]
snippetCode = "location-form"
snippetName = "Locations"
snippetProperties[category][title] = "Select Category"
snippetProperties[category][type] = "dropdown"
snippetProperties[category][default] = "customer"
snippetProperties[category][options][customer] = "Customer"
snippetProperties[category][options][agent] = "Agent"
[builderList]
modelClass = "Tech\Locations\Models\Location"
scope = "-"
scopeValue = "{{ :scope }}"
displayColumn = "name"
noRecordsMessage = "No records found"
detailsPage = "-"
detailsUrlParameter = "id"
pageNumber = "{{ :page }}"
[MarkerData]
==
{% set records = builderList.records %}
{% set displayColumn = builderList.displayColumn %}
{% set noRecordsMessage = builderList.noRecordsMessage %}
{% set detailsPage = builderList.detailsPage %}
{% set detailsKeyColumn = builderList.detailsKeyColumn %}
{% set detailsUrlParameter = builderList.detailsUrlParameter %}
{% component "MarkerData" %}
I want my form to hit the method defined in component. Is there any other way to submit form via ajax in OctoberCMS
In your partial code you need to add
after that it will add
MarkerDatato that page soOctoberCMScan findthat component and its Ajax-handlerif any b\doubt please comment.