this is about angular material's chips,
you know that, not allowed same name on it,
so i want to make a count how many times I write same name on it.
for example:
Apple (1), Papaya (1), Pome (1).
after that I write "Pome" again and it'll become like this,
Apple (1), Papaya (1), Pome (2).
thank for your help...
var app = angular.module('StarterApp', ['ngMaterial']);
app.controller('AppCtrl', ['$scope', '$mdSidenav', function($scope, $mdSidenav)
{
$scope.names = [];
$scope.isReadonly = false;
}]);
body{
padding: 20px;
}
<script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-messages.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div ng-app="StarterApp" ng-controller="AppCtrl">
Tags :
<md-chips ng-model="names" readonly="isReadonly"></md-chips>
<br/>
<input type="checkbox" ng-model="isReadonly">Enabled</input>
</div>
just wanna adding some feature to the chips to count ho many times i write the same words on it
Related
I think I understand how placeholders work regarding select2 library.
There is a thing bugging me for a while already, how to have non-escaped placeholder on multiple selects.
The reason is I like to place an icon at the placeholder.
Single selects uses an additional option tag and the property escapeMarkup at the select2 options object.
$('mySelector').select2({
escapeMarkup: function(markup){
return markup;
}
});
Nothing of that is possible at multiple selects since the placeholder is placed at an input tag, so html markup is escaped and you get the <i> tag instead of the icon.
Is there a workarund for this?
#Marcos i have done some solution regarding placeholder regarding select2 library.
<select class="select2 selectPlaceholder" multiple="multiple"></select>
<script>
$(".selectPlaceholder").select2({
placeholder: "Select Product",
allowClear: true
});
</script>
Optional
allowClear: true
Please let me know if i am right because i got your question but still i have some doubt
understanding Que.
Taking your previous comment as a reference:
"the idea is to place a font awesome icon at the placeholder and
preventing select2 from escaping it, and i'm getting the i tag instead
of the icon"
...and if I understood correctly, you want to place a Font Awesome icon on the Placeholder of the Select2 element and keep it there, correct?
Check the following code where I'm inserting a DIV that contains a Font Awesome icon (the little airplane) and placing it on top of the Input used for searching. Even when you select different items from the Select (is a Multiple Select as you needed) the icon remains in the placeholder and also it has a text by default.
Remember to add the class="tab" in case you don't see the Icon.
$(document).ready(function(){
$("#sel1").select2({
placeholder: 'Search here...',
allowClear: true
});
$(".select2-search.select2-search--inline").prepend("<div class='fab'></div>");
});
select {
width:300px;
}
.multi {
padding:10px;
font-family: FontAwesome, "Open Sans", Verdana, sans-serif;
font-style: normal;
font-weight: 600;
text-decoration: inherit;
}
.top {
position: absolute;
left: 0px; top:0px;
}
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- select2 -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<!-- select2-bootstrap4-theme -->
<link href="https://raw.githack.com/ttskch/select2-bootstrap4-theme/master/dist/select2-bootstrap4.css" rel="stylesheet"> <!-- for live demo page -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- select2 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
</head>
<body>
<div class="container-fluid" style="width: 100%;">
<select class="multi fab" multiple placeholder="" data-allow-clear="1" id="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<script>
</script>
</body>
</html>
i am trying to use this Date time Picker in MVC, its been hours but picker screen is not showing up, i also tried this
BundelConfig.cs
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/moment.js",
"~/Scripts/bootstrap.js",
"~/Scripts/bootstrap-datetimepicker.min.js"
));
// other bundles here
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/site.css",
"~/Content/bootstrap.css",
"~/Content/bootstrap-datetimepicker.min.css"
));
// other bundles here
My View:
<script src="~/Scripts/jquery-1.9.1.js"></script>
<script src="~/Scripts/moment.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
</div>
</div>
_Layout:
<!DOCTYPE html>
<html>
<head>
#Scripts.Render("~/bundles/modernizr")
#Styles.Render("~/css/boostrap.css")
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
</head>
<body>
<div>
// here other divs
#RenderBody()
</div>
<script src="js/jquery.js"></script>
<script src="js/boostrap.min.js"></script>
#section Scripts {
#Scripts.Render("~/bundles/jqueryval")
}
#Scripts.Render("~/bundles/jquery")
#RenderSection("scripts", required: false)
</body>
</html>
Expected output
http://jsfiddle.net/RR4hw/7/
i am not able to figure out what i am doing wrong ?, Any help would be appreciated.
You are including jQuery multiple times. Your bundle already included it, so you can remove this line in your layout:
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
and these lines from your view:
<script src="~/Scripts/jquery-1.9.1.js"></script>
<script src="~/Scripts/moment.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
This line in your Layout
#Scripts.Render("~/bundles/jquery")
is doing it all for you, because you added those scripts to that bundle.
Including the same script multiple times impacts negatively on performance, but wouldn't normally stop the code from working. However, in this case the different versions of jQuery that you've included are all different versions. I would check what is in your Scripts folder and see if it is up to date.
As an aside, it's also considered good practice to put styles (e.g. CSS) at the top of the page and scripts at the bottom, because that way the browser will load the page properly with styling, and not be slowed down by trying to load scripts halfway through (and if there's a problem with the script, the page still loads).
And as a final aside, you also look like you are a bit confused about the difference between .min.js and .js (I'm extrapolating from the fact you sometimes use the min version and sometimes don't; if you know all this already please excuse me!). The .min.js files are a minimised version (variable names as short as possible, comments deleted, whitespace reduced to minimum) that can be sent to the server. You may already have something like this
#if DEBUG
BundleTable.EnableOptimizations = false;
#else
// note: overrides compilation debug="true" in Web.config
BundleTable.EnableOptimizations = true;
#endif
in your Bundle.Config file. If not, it's handy to add because it means that the release version has the best performance (.min.js files) but the debug version is more human-readable (normal .js files) to help you debug it.
I am trying to get a jQuery-ui div under the class ui.state.alert to fade into the page as it loads so that users notice it. I have added the fadeTo in a js file but when the page loads, the alert just appears, with no fade effect at all. I have even made sure the 'slow' attribute is added. Here is the html code.
<div class="ui-widget">
<div class='ui-state-error ui-corner-all' id="serviceAlert" style="opacity: .1">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right:
.3em;"></span><strong style="color: #1F1F1F">Alert!</strong> Sign Up Services are
currently under construction. Please check back later for further updates.</p>
</div>
</div>
And here is my jQuery file:
$(document).ready(function() {
$('#serviceAlert').fadeTo(1,'slow');
});
I have added the following scripts to my header:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script type="text/JavaScript" src="jquery-ui-1.10.4.custom\js\jquery-ui-1.10.4.custom.js"></script>
<script type="text/JavaScript" src="js/script.js"></script>
The first Parameter of fadeTo is the duration, here you have to define a number in ms oder slow etc. Your animation is currently only running for 1 ms (thats a bit short (-: ).
.fadeTo( duration, opacity [, complete ] )
You've done it the other way around.
Example:
$('#serviceAlert').fadeTo(1000, 1); //fades in 1sec to opacity 1
I'm building a jQuery Mobile page that incorporates a Google map (API v3). So far I have been successful displaying the map and implementing a lot of functionality. My problem is that the zoom feature on the google map does not render properly (it looks broken up and pixely).
The code at the bottom of the page demonstrates a basic implementation of a Google map in jQuery Mobile. If you test it on the latest version of Firefox you should see the zoom problem. Notice if you comment any of the three libraries below the zoom feature renders properly but the jQuery mobile functionality is lost.
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css"/>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
The research I've done indicates that the libraries implemented in these examples might fix the issue, but it will require me re-writing a large number of methods. Can any one advise me on a simpler way to fix this.
Sample Code:
<head>
<style type="text/css">
#map_canvas {
height: 375px;
width: 550px;
padding:10px;
border:1px solid gray;
margin:10px;
}
</style>
<link rel="stylesheet" href="../_assets/css/jqm-docs.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="//maps.googleapis.com/maps/api/js?sensor=false&libraries=places"
type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css"/>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
</head>
<body onload="initialize()">
<script type="text/javascript">
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(37.332619, -121.88440100000003),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
</script>
<div data-role="page">
<div data-role="header"></div>
<div data-role="content">
<div id="map_canvas"></div>
</div>
</div>
</body>
I am using the plugin you mentioned (http://jquery-ui-map.googlecode.com/svn/trunk/demos/jquery-google-maps-mobile.html) and recommend you to use this with jQM.
The plugin also struggles with some rendering failures on jQM and recommends to refresh all maps on pageshow.
Leads to code like:
jQuery(document).bind('pageshow', function(e, data) {
var page = jQuery(e.target);
page.find('.gmap').gmap('refresh');
});
You should try to do this somehow without the plugin.
I've been trying to get a script that inserts a div of text after the first and second paragraph of an article to work in jQueryMobile. It works on the first pageload, but on the second it loads the content twice, and the third time it's loaded three times, and so on.
The jQueryMobile libraries and my script is loaded in the head:
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="myscript.js">
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
Then I have
<body id="mobile">
<div id="wrapper" data-role="page">
And then the content of the page
My script is executed as documented on jquerymobile.com
$("#wrapper").live('pageinit', function() {
Am I missing something? Any help will be deeply appreciated.
try adding data-dom-cache="false" it should look like this
<body id="mobile">
<div id="wrapper" data-role="page" data-dom-cache="false">
As Clarence commented, a better solution is to move the <script> tag outside of the <div> with data-role="page"
<body id="mobile">
<div id="wrapper" data-role="page">
<!-- stuff -->
</div>
<script>
$("#wrapper").live('pageinit', function() {
// more stuff
});
</script>
</body>