"change" event in mobile version

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
GT73
User
Posts: 415

"change" event in mobile version

Post by GT73 »

I have a problem with loading javascript. I have hidden fields with the key function in "Client Side Events". When I load the page (add) the field is set to the correct value "1" the field and set as "Select". When I use the mobile version, even if the field is set to "1" all fields remain visible. To resolve I have to "reselect" the field manually. It seems that when the "add" page is loaded only in the mobile version the javascript code is not executed. Using the field with the default value of "1" I also tried to use "Page_Render ()" to set the default value, but from the mobile version the problem remains.

(movimenti_add.php)

// Page Render event
function Page_Render() {

	//echo "Page Render";
	$this->idCausaleMov->CurrentValue = '1';
}

// Load default values
protected function loadDefaultValues() {
$this->idCausaleMov->CurrentValue = 1;
...

(uservevt15.js)

// Table 'movimenti' Field 'idCausaleMov'
$('[data-table=movimenti][data-field=x_idCausaleMov]').on(
	{ // keys = event types, values = handler functions

		//"click": function(e)
		"change": function(e) {

// Your code
console.log("idCas:"+this.value);
if (this.value == "0" this.value == "" this.value === "{value}" this.value == "1" this.value == "2") { // buying or cancel
$(this).fields("field1").visible(false);
$(this).fields("field2").visible(false);
$(this).fields("field3").visible(false);
..


arbei
User
Posts: 9384

Post by arbei »

If your field's Edit Tag is SELECT or RADIO, you may need to use the "updatedone" event, see the topic Server Events and Client Scripts > Table-Specific -> Add/Copy page > Client Script > Example 3 in the help file.


GT73
User
Posts: 415

Post by GT73 »

I use the ClientScripts event -> TableSpecific -> StartupScript or ClientScripts event -> TableSpecific -> ClientScript (header/footer)
But the event it's not loaded correctly all the refresch a page (pageadd.php) and when load the page. If I select manual all element hide correctly, This only with mobile version

//wait for page to load
$(function () {
//trigger change event of your field that is responsible for hiding the other field
$( "#x_idCausaleMov" ).change();
});

I tried to change this.field with jQuery var $row = $(this).fields(); but it's same


mobhar
User
Posts: 11727

Post by mobhar »

As arbei said, you should use "updatedone" event to trigger displaying the selected value after all the options have been already updated/done.

Please search in this forum by using "updatedone" keyword, then you should find some useful references.


Post Reply