EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on June 13, 2014, 04:34:58 PM



Title: Setting POST variables for Tree and POST method for a form
Post by: devnull on June 13, 2014, 04:34:58 PM
There does not appear to be a queryParams property for the tree when using POST method.

How can I set the queryParams for a POST tree without using the url variable ?

Also, how do I set the form to use POST and also set it's queryParams ?



Title: Re: Setting POST variables for Tree and POST method for a form
Post by: stworthy on June 14, 2014, 04:42:47 AM
Please override the 'loader' function to support the 'queryParams' property.
Code:
$('#tt').tree({
loader: function(param, success, error){
var opts = $(this).tree('options');
if (!opts.url) return false;
$.ajax({
type: opts.method,
url: opts.url,
data: $.extend({},param,opts.queryParams||{}),
dataType: 'json',
success: function(data){
success(data);
},
error: function(){
error.apply(this, arguments);
}
});
}
})


Title: Re: Setting POST variables for Tree and POST method for a form
Post by: devnull on June 17, 2014, 04:28:40 AM
Thanks, but how can I also set the method to POST for a form ??



Title: Re: Setting POST variables for Tree and POST method for a form
Post by: stworthy on June 17, 2014, 05:47:04 PM
The 'method' attribute of form element can be set to specify the HTTP method.
Code:
<form id="ff" method="post" action="...">
...
</form>
The 'form' plugin has no 'queryParams' property, you have to add the extra parameters to the hidden input, or use the 'onBeforeLoad' event to specify the http parameters.
Code:
$('#ff').form('submit',{
  onBeforeLoad: function(param){
    param.p1 = ...;
    param.p2 = ...;
  }
});