TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kohana 3.2.2 ajax load view
  • Hello, i use kohana 3.2.2

    I use http://hayageek.com/docs/jquery-upload-file.php file upload plugin all work fine when i load page with all form and file input field but now i want to load view with ajax. All loads fine but image uploader does'n work. Why? Im new i kohana maybe you know difrent way to load view without ajax? sorry for bad english. My first load view:

           <?=Form::open($route, array('enctype'=>'multipart/form-data','name'=>'form_add','onsubmit'=>'javascript:return validate("form_add","marke","model","p_category","year","price","condition","name","mobil","city");'))?>
            <div class="parts_table_row">
                <div class="parts_title"><?echo __('marke');?></div>
                <select  id="cat"  name="cat"  class="category" >
                    <option value=""  selected>----</option>
                    <option value="1"  >Bus</option>
                    <option value="2"  >Minibus</option>
                    <option value="3"  >Truck</option>
                </select>
            </div>
    
            <div class="upload_area" id="out_area"></div>
            <?=Form::close()?>
    

    When ajax:

    $('#cat').on('change', function() {
    var id = $(this).val();
    $.ajax
                    ({
                        type: "GET",
                        data: {id: id},
                        url: "/ad/change/",
                        cache: false,
                        success: function(data) {
                                                    $('#out_area').html(data); 
                                                 }
                    });
    });
    

    JS file upload script loadedin first view:

    $(document).ready(function()
    {
    var uploadObj = $("#fileuploader").uploadFile({
    url:"<?php echo Url::base()?>ad/images/<?php echo $code?>",
    fileName:"images",
        showProgress: true,
        showStatusAfterSuccess:false,
        maxFileCount: 5,
        showDelete: true,
        uploadButtonClass:"ajax-file-upload-button-new",
        dragDropStr: "<span><b>Tempti ir Mesti nuotraukas</b></span>",
            abortStr: "Abort",
            cancelStr: "Cancel",
            deletelStr: "Delete",
            doneStr: "Done",
            multiDragErrorStr: "Multiple File Drag &amp; Drop is not allowed.",
            extErrorStr: "is not allowed. Allowed extensions: ",
            sizeErrorStr: "is not allowed. Allowed Max size: ",
            uploadErrorStr: "Upload is not allowed",
            maxFileCountErrorStr: " is not allowed. Maximum allowed files are:",
        onLoad:function()
            {  
                $.ajax
                    ({
                        type: "POST",
                        url: "/ad/gallery/<?php echo $code?>", 
                        cache: false,
                        success: function(data) {
                                                    $('#picasso').html(data);
                                                 }
                    });
           },
        afterUploadAll:function()
            {
    
                $.ajax
                    ({
                        type: "POST",
                        url: "/ad/gallery/<?php echo $code?>",
                        cache: false,
                        success: function(data) {
                                                    $('#picasso').html(data);
    
                                                 }
                    });
    
    
    
            },});});
    

    AJAX load view:

            <div class="upload_area">
                <div id="fileuploader">Upload</div>
                <div id="picasso" class="sortable" ></div>
            </div>