Search code examples
javascriptx-editable

How to edit x-editable value after submit


I want to edit the input value from the submitted form by performing encodeURI on the value so that the value will be a url type.

Example:

$("#smsapi").editable({
    type: "text",
    pk: 1,
    name: "smsapi",
    editValue: function(value){
        value = encodeURI(value);
        return value;
    },
    title: "Enter Your SMS Api Url Exluding message parameter",
    validate: function(
        if($.trim(value) == "") return "This field is required";
    }
});

Then continue with the submission. Thank you for your response in advance.


Solution

  • I was able to modify the input by using the x-editable params method.

    params: function(param){
            param._token = "{{csrf_token()}}";
            param.value =  encodeURI(param.value)
            return param
          },