Menu

#96 New sgsML function

open
7
2013-09-23
2013-09-23
No

Feature Request for a sgsML new attribute to be added to sgsml_parser for dynamic content that utilizes ajax

Syntax Example
'<'field …. >
"<"dynamic="firstfield|function|callback"<"optional>" >

the quotes were added or it would not show on this page*

firstfield is another field, whose '<'field …> tag would be replaced with form_onchange="
var prefix = form_get_prefix(this);
var params = [val(this)];
ajax('dynamic::ajax_function::, params, function(data) { set_val(prefix+'thisfield', data });
">

And function would be a normal function in sgs but we create a function ajaxify
return ajax_function;

etc.

The callback is optional to add proper other code like populate etc, though default is set_val this to data json decoded.

This way people can write cascading drop downs easily, for example

 ajax('dynamic::ajax_dbselect("simple_categories", "categoryname,categoryname" , "cattype=@firstfield@|categoryname, params, { set_val(prefix+'thisfield', data });

SAME AS

<dynamic="firstfield|dbselect|simple_categories|categoryname,categoryname|cattype=@firstfield@|categoryname asc|10"/>

Or to remove the ajaxify requirement just remove the static function require_method requirement.

Discussion


Log in to post a comment.