DMXzone App Connect Support Product Page


The dmx-on:click does not render data

Shared 30 May 2017 06:29:27
like this idea
30 May 2017 06:29:27 Hans Haverlach posted:
I've a dynamic form on a page which is generated with php loop. At one place a INPUT is placed with a onclick event:

<input name="<?php echo $celnaam ?>" type="checkbox" id=""     
checked="checked" dmx-bind:id="<?php echo $celnaam ?>{{<?php echo ($tblidfield); ?>}}" 
dmx-bind:value="{{<?php echo $celnaam ?>}}" 
dmx-on:click="saveMyBoolean(this.form,'<?php echo $tblname ?>',,'<?php echo ($tblidfield); ?>'
,{{<?php echo ($tblidfield); ?>}},'')" /> {{og_name}}

You see that in the onClick event there is a parameter: {{<?php echo($tblidfield):>}} that should render as: {{og_id}} (where 'go-id' is rendered as string by PHP var: $tblidfield)..

The strange thing is that the dynamic data inside the onclick is not rendered. In codeview in the browser you will see {{og-id}} still in place, while the other {{...}} dynamic fields are rendered correctly.

I also tried to not use the PHP, and just put the {{og-id}} in the onclick, but still it is not rendered.

Strange! Do I overlook something?
Thank you for reply!


Replied 30 May 2017 06:39:33
30 May 2017 06:39:33 Teodor Kuduschiev replied:
Hello Hans,
You cannot use php code inside app connect tags ...
Could you please explain what you need to achieve exactly?
Replied 30 May 2017 09:17:15
30 May 2017 09:17:15 Hans Haverlach replied:
Well... actually you can!
This line of code works fine:

dmx-bind:id="<?php echo $celnaam ?>{{<?php echo ($tblidfield); ?>}}"

it renders as: id="og_name1"

Why do I use php?
I developed a dynamic data grid. On top of the page I bind database field names as string values to PHP variables:

Then I use App connect to get data from the database.
In the body the grid is generated.
PHP is rendered server side first so: everywhere where I use {{<?php echo tblidfield; ?>}} inside a repeat region from App connect, it is. rendered correctly!

In the old Databindings extension I could use {{...fieldname}} everywhere inside a repeat region, like:

<input name="{{og_name}}" id="{{og_name}}" onClick="start function({{go_id}},'varname')"/>

Now with App Connect I have to use: dmx-bind:value and dmx-bind:id .That is okay, it works.
But it is not working when you want to use App Connect to add a dynamic event with onclick. The Action picker lets you not choose a database value.

But I found a solution. It is not documented, at least I did not found it, but this works if you want to have a onClick event with dynamic data:

 dmx-bind:onClick="saveMyBoolean(this.form,'<?php echo $tblname ?>',,
'<?php echo ($tblidfield); ?>',{{<?php echo ($tblidfield); ?>}},'')" 

So to conclude:
- You can use PHP to render the fieldnames inside a {{..}} app connect data field.
- You can use onClick or every other attribute with {{...}} by using dmx-bind:attributename="...{{...}}".

It took me hours to find out. A pity that it is not in the documentation or video's. Or is it?
Well I hope it. will serve others well.
Keep up the good work (ánd documentation!!)

Replied 30 May 2017 09:26:56
30 May 2017 09:26:56 Teodor Kuduschiev replied:
Hi Hans,
I still cannot get your idea. What needs to happen on click exactly?
Replied 30 May 2017 09:35:39
30 May 2017 09:35:39 Hans Haverlach replied:
Well, the onclick event needs to trigger a function named: saveMyBoolean().
This function requires a couple off parameters like form name and input name, ID of the grid table, the ID filename off the database table and at last the ID value. -> that is where I needed the {{og_id}}.

It got complicated for you te read, because I used PHP variables rendered as strings to fill in the parameters for the function in combination with App Connect data.

The function itself is used to change a database value. But that was not the issue here.
Replied 30 May 2017 10:02:30
30 May 2017 10:02:30 Teodor Kuduschiev replied:
Function can only be called using static events, in static events dynamic data from app connect is not available.
Replied 30 May 2017 10:19:17
30 May 2017 10:19:17 Hans Haverlach replied:
Okay, so correct me if I am wrong:

In databindings I could use dynamic data inside function call with no problem.
In App Connect it is not possible.
Elsewhere you mention that everything possible with Data bindings is also possible with App Connect.
But that seems not the case.
I wrote one function that, given the right parameters, could update every database table field with a boolean value.

Now with App Connect I can't use that function anymore, because I can't give it dynamic data.
Now I have to work out for every database table where I want to change a boolean value (0 to 1 and v.v.) separate server connect action files. That makes it a lot more troublesome!

I don't understand it. App Connect should be a great extension to streamline things, but somehow I don't get it.
And to make it more complicated, I did find out to use dynamic data inside a static function call with App Connect, as I showed in two replies back. Only you say I can not use it like that. But still it works...

Replied 30 May 2017 10:52:40
30 May 2017 10:52:40 Teodor Kuduschiev replied:
That is how the extension works.
If you need to change database record values you must use server actions of course!
Replied 20 Jun 2017 18:47:36
20 Jun 2017 18:47:36 simon m replied:
I have the same problem.

In the old data bindings it was possible to call custom JS with dynamic fields very easily, i.e - onClick="ga('send', 'pageview', '/somepage/{{id}}');someJSFunction('{{dynamic_data}}')"

With new "dmx-on:click" binding, this is not possible because you are only able to add 1 action to the onClick. So in my case when I set a detail region using the dynamic onClick event, I can no longer call my custom JS with dynamic parameters.....very frustrating, but app connect is very close to being very good.

Is there a forthcoming update to fix this please?
Replied 21 Jun 2017 06:35:05
21 Jun 2017 06:35:05 Teodor Kuduschiev replied:
Hello Simon,
There are two types of events in app connect - static events and dynamic events.
Dynamic events i.e. "dmx-on:" are only used to call App Connect actions (components) like setting an url variable, setting a value, running a server connect action etc.
For custom js functions, you should use the static events and call them there.
Replied 21 Jun 2017 08:42:17
21 Jun 2017 08:42:17 simon m replied:
Hi Teodor,

I understand that. But when I want to call custom JS using the static events, I cannot pass dynamic data as a parameter.

This was possible in the old data bindings.... onClick="ga('send', 'pageview', '/somepage/{{id}}');someJSFunction('{{dynamic_data}}')"

Also, I would need to call more than one action usinf dmx-on dynamic event. At the moment it is possible to only call one action.
Replied 21 Jun 2017 09:43:25
21 Jun 2017 09:43:25 George Petrov replied:
Hi Simon,

We will improve App Connect in the next update to be able to use javascript templates populated with dynamic data in the dynamic events like dmx-on:click, so you will able to do:
dmx-on:click="ga('send', 'pageview', '/somepage/{{id}}');someJSFunction('{{dynamic_data}}')"

in the next update. So hold on a little bit till we finish it.

Replied 21 Jun 2017 09:57:52
21 Jun 2017 09:57:52 Hans Haverlach replied:
Yeah, great! That was what I meant and hope for.
Keep up the good work!
Replied 21 Jun 2017 11:05:57
21 Jun 2017 11:05:57 simon m replied:
Thanks George.
Looking forward to the update.
Replied 26 Jun 2017 14:36:20
26 Jun 2017 14:36:20 Teodor Kuduschiev replied:
Hi all,
Please update your extension to the latest version and check the following tutorial:
Replied 26 Jun 2017 14:50:37
26 Jun 2017 14:50:37 simon m replied:
Thanks Teodor,

Are we now able to perform 2 actions with one Dynamic onClick event. eg Set the key ID of a detail region and also call some custom JS?

Reply to this topic