0

I'm trying to use a jquery plugin to resize the column of a table, here there is an explication : Resizable table columns with jQuery , is the part of colResiazable. This plugin works whit a standard html table :

<div id="searchTable">
    <div id="container" style="position: relative">

        <table id="normal" width="100%" border="0" cellpadding="0"
            cellspacing="0" class="coverhidtable">
            <tr>
                <th>header</th>
                <th>header</th>
                <th>header</th>
            </tr>
            <tr>
                <td class="">cell</td>

            </tr>
            <tr>
                <td class="">cell</td>

            </tr>
            <tr>
                <td class="">cell</td>

            </tr>
        </table>

    </div>
</div>

but it stops to work when i use an angularJs table :

<div id="searchTable">
    <div id="container" style="position:relative">
        <table id="normal" width="100%" border="0" cellpadding="0"
            cellspacing="0" class="">


            <tr class="tableList-head" >
            <th ng-hide="hd.hidden"  ng-repeat="hd in conf.heads">
                        {{hd.name}}
                    </th>
            </tr>


                <tr ng-repeat="data in conf.myData" >  
                    <td  ng-hide="d.hidden" ng-repeat="d in conf.heads">
                        {{data[d.name]}}</span>

                    </td>   
                </tr>   

        </table>

    </div>
</div>

The angularJs table is an angular directive :

.directive('angTable',['$compile',function($compile) {
                            return {
                                restrict : 'E',
                                templateUrl : 'components/table/tableTemplate.html',
                                replace : true,
                                scope : {
                                    conf : "="
                                },
                                controller : function($scope,$rootScope) {

and here inside the declaration of the directive i add the jQuery code for make the jQueryplugin works :

$("#normal").colResizable({
    liveDrag:true, 
    gripInnerHtml:"<div class='grip'></div>", 
    draggingClass:"dragging", 
    resizeMode:'fit'
});

Now, in the first table it works, while in the second it doesn't. I read something about angularJs modification of the dom and i guess that the problem should be that, i mean maybe the id "normal" of the table is not retrived, but i'm new of angular and i don't know how to fix it. Any suggestion would be appreciated

2
  • if you want to use jquery must be include before angular js files.may be you include jquery lib before angular. Commented Jun 15, 2016 at 8:08
  • @ SSH what do you mean, where i should insert the jQuery code ? Commented Jun 15, 2016 at 8:11

1 Answer 1

1

For this you have to include jQuery library before angular and you have to put that code inside link function of DDO:

link:function(scope, el, attrs){
    $("#normal").colResizable({
        liveDrag:true, 
        gripInnerHtml:"<div class='grip'></div>", 
        draggingClass:"dragging", 
        resizeMode:'fit'
    });
}
Sign up to request clarification or add additional context in comments.

1 Comment

I already have a compile for my directive, can be the same :

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.