Cjax Framework


Project development is new to github. Give us a star.

Bind elements to commands


Basically both anchor are hooked by the same event used

Examples

PHP
<?php 

$ajax
->click("#link1,#link2",$ajax->call("ajax.php?bind/bild_elements"));

?>
HTML
    <a href='#' id='link1'>Click Me (element 1)</a>
    <a href='#' id='link2'>Click Me (element 2)</a>

Try it


Click Me (element 1)
Click Me (element 2)

Using Advanced Selector Cjax 5.9+

You can use wildcard selectors, or class selectors, or any type of advanced selectors, supported by popular libraries.

In these examples we feature CSS/style properties, you can use any available property in CSS.

This does not limit the properties you may use to CSS. You may use any DOM property entirely, that the element may support.

If you know CSS, you already know how to use this whole system, without much of a learning curve. If you know even a little about the properties in JavaScript, this is a walk in the park. Otherwise you can just review the docs

Although advanced selectors are available since Cjax 5.7 (2012), the uses in these examples are new. For example: Using prop() and swap() methods.

PHP
<?php 



     
//Apply CSS properties to any element you click on, containing the class '.red'. When clicked on, will change to green.
    
$style = array(
        
'style' => array(
            
'backgroundColor' => 'green'
        
));

    
$ajax->click('.red'$ajax->prop($style));


    
//Apply CSS properties to any element you click on, containing the class '.blue'. When clicked on, will change to yellow.
    
$style = array(
        
'style' => array(
            
'backgroundColor' => 'yellow'
        
));

    
$ajax->click('.blue'$ajax->prop($style));


    
//Reset the style.backgroundColor property style
    
$style = array(
    
'style' => array(
        
'backgroundColor' => ''
    
));

    
//prop() supports parameter to specify selectors to apply the properties to.
    //If not specified - by default it would apply them to the element you click on.
    
$ajax->click('.grey'$ajax->prop($style,'.blue , .red'));


    
//When you click on any element that contains the class .grey, it will trigger a swap of class red and blue.
    
$ajax->click('.grey'$ajax->swap('blue','red'));

    
?>
HTML

        <div class="red"></div>
        <div class="blue"></div>
        <div class="red"></div>
        <div class="blue"></div>
        <div class="red"></div>
        <div class="grey"></div>

    

Try it


Previous Topic:  Previous Class    ·   Top of Page   ·   Demos Home   ·  

CodeIgniter  ·  Copyright © 2006 - 2012  ·  Cjax