How to disable html boutton link in JS

Hello everyone,
I have a button link, inside a TD ,which i have to disable, if the status of contract is signed.

so in : root\crmPrj\custom\modules\P_Asw_Contrat\metadata\listviewdefs.php
i added :

$(function(){ $('#MassUpdate .list.view > tbody > tr').each(function(){ var chkvalue=$.trim($(this).find('td:eq(9)').html()); if( chkvalue=="Signed" ){ $(this).find('td:eq(1)').find('a').removeAttr('href').addClass('editbtn_disable'); } }); }); but it doesnt work :( Thank u for ur help

You can’t run javascript directly in the listviewdefs.php file. You need to link to a javascript file by adding it to the array like:

'includes' => 
      array (
        0 => 
        array (
          'file' => '~Location of Javascript File',
        ),

Then add your javascript to the included file.

I did it, but it still does not work

Hi,

You can do it at module level as well as application level.

This is a code for application level.

create a file - custom\include\ListView\ListViewSmarty.php

User following code.


require_once ('include/ListView/ListViewSmarty.php');

class CustomListViewSmarty extends ListViewSmarty {

 function CustomListViewSmarty() {

        global $app_strings;
        parent::ListViewSmarty();
 }

function display($end = true){
		
		if( isset($this->lvd->seed->object_name) && $this->lvd->seed->object_name == '<yr module object'>'){
			foreach ($this->data['data'] as $key => $value) {
				if($value['STATUS'] == "signed"){
					$this->data['pageData']['rowAccess'][$key]['edit']=0;
				}
			}
		}
		
		return parent::display($end);
	}
}

I hope it will help you.

Regards,
Alpesh

and where, is what I call the js file?