Help with form.getValues

Hi Guys

I’ve only just started playing with Webix, so probably a stupid mistake. I can’t get $$(“form”).getValues() to work, where $$(“edit”).getValue() does work… Could somebody please point me in the right direction -

	var add_category_click = function()
	{
		// webix.alert($$("ex1").getValue());
		webix.alert($$("category-form").getValues());
	}

	var category_win = {
		view : "window",
		modal : true,
		position : "center",
		id : "category-win",
		css : "bradius",
		head : { height : 38, template: "New category" },
		body : {
				view : "form",
				id : "category-form",

				padding : 18,
				elements : [
							{ view:"text", value:"Extra 1", label:"Ex 1", name:"ex1" },
							{ view:"text", value:"Extra 2", label:"Ex 2", name:"ex2" },
					{ cols:[
						{ view:"button", label:"Add", width:150, click: add_category_click },
						{},
						{ view:"button", label:"Cancel", width:150, click: '$$("category-win").hide();' },
					]}						
				]
		}
	};
	
	webix.ui(category_win).show();

Also just a side note, not sure if alert() would display an array (javascript newb!) but I’ve tried webix.ajax() and whilst the request is sent to the server, there is data in the request.

You actually get form values… You can convert JSON object to a string to see them.

http://webix.com/snippet/be76cb95

Amazing, thanks Helga :smiley:

Just one more question, what about sending those values back to the server with AJAX, I’ve tried what is shown in the documentation

webix.ajax("/cat/test1", $$(“category-form”).getValues());

and

webix.ajax.post("/cat/test1", $$(“category-form”).getValues());

Whilst the server recieves the GET request, POST does not work and their are no values in the $_GET.

It must be webix.ajax().post(url, data) and webix.ajax().get(url, data)

http://webix.com/snippet/15315c56

I think we will add webix.ajax.post as alias in the next update, as this is quite common error.

Excellent, thanks Maksim :slight_smile:

I’ve learnt a lot by just pulling the samples and demos apart, if there was an AJAX section I think it would go a long way to help newbies :slight_smile: