1

here is the angularJS directive using jquery UI. I want to set maximum width of the element that can be resize within the resize function. How does that possible?

 app.directive('resizable', function () {

        return {
            restrict: 'A',
            scope: {
                callback: '&onResize'
            },
            link: function postLink(scope, elem, attrs) {
                elem.resizable({ grid:200,  handles: 'e,w'});
                elem.on('resize', function (evt, ui) {


                            scope.$apply(function() {   
                                if (scope.callback) { 
                                    scope.callback({$evt: evt, $ui: ui }); 


                                    //here is where I want to set maximum width


                                } 
                            })



                });


            }
        };
    });

1 Answer 1

1

According to API docs you just have to set the maxWidth option :

$( ".selector" ).resizable({
  maxWidth: 300
});

You can also call it dynamically :

$( ".selector" ).resizable( "option", "maxWidth" );

the fact is if you call it from the resize event handler, I think the change will only affect the next trigger.

Sign up to request clarification or add additional context in comments.

6 Comments

yes we can set maximum width like that. but what i need is i want to set the maximum width dynamically within the resize function.
ok, so WHY do you want to do that, because it seems a bit hazardous..?
i want to get the element width from ui object like ui.size.width and according to that value I have to change the maximum resizable width.
the problem is that the change will affect the next resize event not the current one
we can set it like this ui.size.width < maxwidth
|

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.