EasyUI Forum
June 22, 2024, 07:26:25 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Setting POST variables for Tree and POST method for a form  (Read 6250 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« 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 ?

« Last Edit: June 13, 2014, 04:37:23 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
}
});
}
})
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: June 17, 2014, 04:28:40 AM »

Thanks, but how can I also set the method to POST for a form ??

Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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 = ...;
  }
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!