Rajan
Rajan

Reputation: 2425

Open new tab on button click using JQUERY

My Scenario is this:

I have edit user module. Each user has been allocated a Base INI File. When we edit a user, we have a dropdown from which we select a his Base INI File

After selection we may save the user. and the id of selected file is also saved.

This is working fine.

But, when we edit a user i have an option to let user make a custom_ini_file. So when he clicks on the edit button code copies the content from one file and creates a new file and let user make custom changes in that and then that file will be saved.

Now i want to open this edit custom_ini_file in new tab or windows and keep the user edit page open. Once he completes editing the file then and only then he can go back to editing user and save users as well.

So basically he should be able to edit a user and a file.

Now in edit user i have a dropdown like this along with edit button:

<tr>
    <td>Base INI File</td>
    <?php 

        if(isset($_GET['id'])) { 
            $id=$_GET['id']; 
            btn_edit($id); 
        } 
    ?>  
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> 


    <td> 
        <select required name="base_ini_id" id="base_ini_id" class="form-control"> 
            <option value="">Select</option> 
            <?php foreach($base as $value) { ?> 
                <option id="emp" class="specialLink" value="<?php echo $value->id;?>"><?php echo $value->base_ini_filename;?></option> 
            <?php } ?> 
        </select> 
    </td> 
    <td> 
        <?php echo btn_edit('customer/upload_ini/edit_ini_custom/'); ?> 
    </td> 
    <script type="text/javascript"> 
        $(document).ready(function() { 
            $('#base_ini_id').change(function() { 
                var id = $("#base_ini_id").val();
                var url = "/project/customer/upload_ini/edit_ini_custom/";

                $("#edit_link").attr("href",url+ id); 

            }); 
        }); 
    </script>
</tr>

Edit Button

function btn_edit ($uri)
{
    return anchor($uri, '<i class="glyphicon glyphicon-edit"></i>','id="edit_link"');
}

Upvotes: 2

Views: 3040

Answers (1)

Santosh Ram Kunjir
Santosh Ram Kunjir

Reputation: 1082

In helper

 anchor($uri, '<i class="glyphicon gl yphicon-edit"></i>','id="edit_link"'); 

Replace this with following it will work

 anchor($uri, '<i class="glyphicon glyphicon-edit"></i>',array('id'=>"edit_link", 'target'=> '_blank');

in jquery

$("#edit_link").attr("target","_blank");

Upvotes: 2

Related Questions