Rss Feed
  1. Jquery function passing parameters!!

    Wednesday, 28 November 2012




    php echo $row['id']; ?>">Edit User
    $('a.edit').click(function () {
        var id = $(this).data('id');
        // do something with the id
        return false;
    });

  2. JQuery website for ajax content, pagination, email check, and more....


    http://www.mix26.com/

  3. JQuery Auto complete plugin


    http://jqueryui.com/autocomplete/

    Html->script('jquery-ui'); ?>
    Html->css('jquery-ui'); ?>  

       

       
     


    Html form

    Form->input('place',array('label' => '','id' => 'LocationmasterName', 'title' => 'Local search...'));  ?>



  4. Note: Ignore all comments

    SCRIPT

    <script type="text/javascript">var myBaseUrl = '<?php echo $this->base; ?>';</script> // finds the base URL
    <script type="text/javascript">
    $(document).ready(function(){
       
        $('#DealTypemasterId').change(function(){ // when dropdown value gets changed function executes
        $.ajax({
            type : "POST",
                    url  : myBaseUrl + ('/deals/populateSubcat') + '?q=' + $("#DealTypemasterId option:selected").val(), //pass query string to server
                    success : function(opt){
                            document.getElementById('DealSubcatId').innerHTML = opt;   // assign the output to another dropdown
                        }
                })
                });
                });
           
    </script>


    HTML


    <?php echo $this->Form->create('Deal');?>
    <?php echo $this->Form->input('typemaster_id', $typemasters);?>
    <?php echo $this->Form->input('subcat_id', $subcats);?>
    <?php echo $this->Form->input('merchantmaster_id', $merchantmasters);?><br />
    <?php echo $this->Form->end(__('Submit', true));?>


    PHP

    Controller:
    //fetch all data from database

        function populateSubcat()
        {
           
        $location = $this->Subcat->find('list', array('fields' => array('name')));
    $this->set('locations', $location);
    $this->layout = 'ajax';

        }  


    View:
    //print the values set in controller in the format of javascript array, which is needed for autocomplete jquery. 
    <?php 
    $locat = implode(',', $locations);
    echo $locat;
    ?>




  5. Jquery functions for event



    $(document).ready(function(){
    $("#yourid").focusout(function() {

    alert('coding here');

    });
    });

  6. $('#yourElementId').attr('title', 'your new title');
    var assign = $('#yourElementId').attr('title');

  7. Paasing parameter and submitting image using form

     <?php echo $this->Form->create('Deal', array('url' => array($mid,$mname),'type' => 'file'));?>