javascript - How can I enabled a ng-click action of a <div class="row"> according to the screen size with bootstrap classes? -
i'm using angularjs , twitter bootstrap form app.
<div class="row"> <div class="col-xs-12"> <div class="row yo-bold"> <div class="col-xs-6 col-sm-5"> {{ "key" | translate | capitalize}} </div> <div class="col-xs-6 col-sm-5"> {{ "labels" | translate | capitalize}} </div> <div class="hidden-xs col-sm-2"> {{ "actions" | translate | capitalize}} </div> </div> <hr /> <div class="row yo-mb5 yo-div-table" ng-repeat="l in langs | filter:searchtext | orderby: '_id' track $index" ng-class="$index % 2 == 0 ? 'yo-bg-grey' : ''"> <div class="col-xs-6 col-sm-5"> {{ l._id }} </div> <div class="col-xs-6 col-sm-5"> <div class="row" ng-repeat="lang in langsavailable track $index"> <div class="col-xs-12"> <flag country="{{lang | getlangcode}}" size="16"></flag> {{ l[lang] }} </div> </div> </div> <div class="hidden-xs col-sm-2"> <button class="btn btn-xs btn-warning" ng-click="openlangmodal(l)"><i class="fa fa-pencil"></i></button> <button class="btn btn-xs btn-danger" ng-click="removelabel(l._id)"><i class="fa fa-trash"></i></button> </div> </div> </div> </div>
in > 768px version (col-sm-*) looks this:
in < 768px version (col-xs-*) looks this:
in version <768px removed column of actions , insert ng-click on entire row, open modal , choose desired action within modal. possible?
i know can creating 2 div class="row" different different screen sizes hidden-xs in first , visible-xs in second wondering if there better way. idea?
the more cleaner , ideal way of doing add custom attribute(ng-click) via jquery when in <768px device width. can done using $(window).width()
.
we adding or removing attribute based on screen width.
if ( $(window).width() < 768) { //code goes here }
how it:
since have used bootstrap assume actions column below <768px screen width vanish.
1) apply class main parent row, <div class="row yo-row">
.
2) use class identify rows , insert ng-click attribute rows.
if ( $(window).width() < 768) { $('.yo-row').attr("ng-click", "openmodal()"); }
3) left add modal div modal open. simple :-)
note: since javascript doing magic , not css, need make scripts run again see change. therefore, need go specific window size , reload show attribute. not work if try re-size browser window desktop small screen , expect apply attribute.
Comments
Post a Comment