From 474195d3aa862686712cfe6c800dc43f8fee8ec5 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 19 Dec 2018 12:14:03 +0100 Subject: An addon remote module for select component. --- .../pl/treksoft/kvision/form/select/AjaxOptions.kt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision') diff --git a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt index 212dc456..fb1ad2fd 100644 --- a/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt +++ b/kvision-modules/kvision-select/src/main/kotlin/pl/treksoft/kvision/form/select/AjaxOptions.kt @@ -77,12 +77,19 @@ enum class DataType(internal val type: String) { * option */ data class AjaxOptions( - val url: String, val preprocessData: (dynamic) -> dynamic, val beforeSend: ((JQueryXHR) -> dynamic)? = null, - val data: dynamic = null, val httpType: HttpType = HttpType.GET, - val dataType: DataType = DataType.JSON, val minLength: Int = 0, - val cache: Boolean = true, val clearOnEmpty: Boolean = true, val clearOnError: Boolean = true, + val url: String, + val preprocessData: (dynamic) -> dynamic, + val beforeSend: ((JQueryXHR, dynamic) -> dynamic)? = null, + val data: dynamic = null, + val httpType: HttpType = HttpType.GET, + val dataType: DataType = DataType.JSON, + val minLength: Int = 0, + val cache: Boolean = true, + val clearOnEmpty: Boolean = true, + val clearOnError: Boolean = true, val emptyRequest: Boolean = false, - val requestDelay: Int = AJAX_REQUEST_DELAY, val restoreOnError: Boolean = false + val requestDelay: Int = AJAX_REQUEST_DELAY, + val restoreOnError: Boolean = false ) /** @@ -109,10 +116,11 @@ fun AjaxOptions.toJs(emptyOption: Boolean): dynamic { return obj { this.ajax = obj { this.url = url - this.type = httpType.type + this.method = httpType.type this.dataType = dataType.type this.data = data this.beforeSend = beforeSend + this.contentType = "application/json" } this.preprocessData = procData this.minLength = minLength @@ -124,5 +132,6 @@ fun AjaxOptions.toJs(emptyOption: Boolean): dynamic { this.requestDelay = requestDelay this.restoreOnError = restoreOnError this.langCode = language + this.processData = false } } -- cgit