Hello.
My module renders a page with a picture and a table within. The table holds a list of properties of something. When user clicks on one table cell it fires JS function which loads a picture of it and replaces the existing one on the page. Sounds simple, but how do I put a JQ listener on page element using Drupal way?
for now there is a hook_menu:

<...>$items['shop/%'] = array(
		'title' => 'one product',
		'title callback' => 'fm_fanshop_load_product_title',
		'title arguments' => array(1),
		'type' => MENU_NORMAL_ITEM,
		'page callback' => 'fm_fanshop_load_product_display',
		'page arguments' => array(1),
		'access callback' => TRUE,
	);

and the page callback:

         function fm_fanshop_load_product_display( $arg )
         {
             ...some code which makes an HTML...
            return $html;
         }

Comments

nitin.k’s picture

Firstly, the cells content should be clickable, now you need to use something like below..


    $link_of_content = l(t('Content'), 'some url', array('attributes' => array('id' => array('some id of element'), 'class' => array(' use-ajax'))));


Now the clickable URL should be defined in hook_menu() and then content should be returned from this callback in the form json.