I m using select2 with Laravel Blade engine and i use it for loading remote data and its work fine (getting data from remote) but its not look like select2 box. i also attach image for my resulting select2.
My CSS file include in section as follows
{{--Bootstrap--}}
{{ HTML::style('css/bootstrap.css') }}
{{ HTML::style('css/bootstrap.min.css') }}
{{ HTML::style('css/plugin/font-awesome.min.css') }}
{{--select2--}}
{{ HTML::style('css/plugin/select2/select2.min.css') }}
{{ HTML::style('css/plugin/select2/select2-bootstrap.css') }}
My Js file include as follows after body tag
{{ HTML::script('js/jquery.min.js') }}
{{ HTML::script('js/bootstrap.min.js') }}
{{ HTML::script('js/plugin/select2/select2.min.js') }}
{{ HTML::script('js/plugin/select2/select2.js') }}
MY HTML code
<input type="hidden" id="student-name-search"
data-placeholder="Select Student" value="" data-option="" style="width:100%"> </input>
Image
enter image description here
You have to use a select input in your HTML like this:
$(document).ready(function() {
$(".js-example-basic-single").select2();
});
<select class="js-example-basic-single">
<option value="AL">Alabama</option>
...
<option value="WY">Wyoming</option>
</select>
Related
This is my login form. If a user puts in a wrong username and does not exists on the server then how do I use md-error to display message?
E.g.
Here is the json I get back for auth from a submit:
{is_username: false, status: false}
Here is how I set up my form:
this.myForm = fb.group({
username: ['',[Validators.required]],
password: ['',[Validators.required]]
})
Here is my HTML:
<md-input-container>
<input mdInput type="email" placeholder="Username" [(ngModel)]="username" formControlName="username" style="width: 300px;outline: none;">
<md-error *ngIf="myForm.get('username').hasError('required')">Username is required</md-error>
<md-error *ngIf="myForm.get('username').hasError('username_exists')">Username does exist</md-error>
</md-input-container>
So..how do I trigger a md-error message if is_username is false?
I've been doing server side validation like this.
<md-input-container>
<input mdInput type="email" placeholder="Username" [(ngModel)]="username" formControlName="username" style="width: 300px;outline: none;">
<md-error *ngIf="myForm.get('username').hasError('required')">Username is required</md-error>
<md-error *ngIf="myForm.controls['username'].hasError('username_exists')">{{myForm.controls['username'].errors['username_exists']}}</md-error>
</md-input-container>
Then, set the error after you get the response from the server.
https://angular.io/api/forms/AbstractControl#setErrors
this.myForm.controls['username'].setErrors({
'username_exists': 'Username does exist'
});
I typically return validation error messages from the server as well, which could be used here.
I upgraded my application from 2.2.3 to 2.4.3. Now when I click submit on the login page, I see that the POST request to j_spring_security_check has status code 302.
Is there something I need to do after upgrading? I've tried running grails clean-all but that did not help.
I'm using this version: compile ':spring-security-core:2.0-RC3'
settings in config.groovy
grails.plugins.springsecurity.userLookup.userDomainClassName = 'com.aerstone.scanner.security.User'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'com.aerstone.scanner.security.UserRole'
grails.plugins.springsecurity.authority.className = 'com.aerstone.scanner.security.Role'
GSP
<form action="${postUrl}" method="POST" id="loginForm" autocomplete="off">
<input type='text' name='j_username' id='username' placeholder="Username"/>
<input type='password' name='j_password' id='password' placeholder="Password"/>
<input type="submit" class="btn" value="Sign in" id="submit"/>
</form>
I had the same issue after an upgrade.
I changed the action of the login form by:
<form action='${ request.contextPath }/j_spring_security_check' method="POST">
Hope that helps
please note that the name had change in the config to be:
grails.plugin.springsecurity....
Notice 'plugin' vs 'plugins'. I've passed this problem but I'm getting invalid credentials all the time.
I'm working up an ember-rails app that precompiles Handlebars assets through the rails pipeline. Everything is updated to the latest versions via bundle update.
When we load the index, the ember data is not rendered to the list, despite (app/views/gigs/index.html.erb):
<h1>Gigs</h1>
<script type="text/x-handlebars">
{{ view App.ListGigsView }}
</script>
<script type="text/javascript">
$(function() {
App.gigsController.loadAll(<%= #gigs.to_json.html_safe %>);
});
</script>
So, I checked the ListGigsView, which contains the following (app/assets/javascripts/app/views/gigs/list.js):
App.ListGigsView = Ember.View.extend({
templateName: 'app/templates/gigs/list',
gigsBinding: 'App.gigsController',
showNew: function() {
this.set('isNewVisible', true);
},
hideNew: function() {
this.set('isNewVisible', false);
},
refreshListing: function() {
App.gigsController.findAll()
}
});
Seems like the templateName is pointing fine (this is similar in, say, new.js). Nonetheless, the browser console (Google Chrome Version 25.0.1364.172) keeps returning the following:
Uncaught Error: assertion failed: You specified the templateName app/templates/gigs/list for <App.ListGigsView:ember194>, but it did not exist.
Here is the file at app/assets/javascripts/app/templates/gigs/list.handlebars:
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{{#each gigs}}
{{view App.ShowGigView gigBinding="this"}}
{{/each}}
{{#if isNewVisible}}
<tr>
<td>*</td>
<td>
{{view App.NewGigView}}
</td>
</tr>
{{/if}}
</tbody>
</table>
<div class="commands">
<a href="#" {{action "showNew"}}>New Gig</a>
<a href="#" {{action "refreshListing"}}>Refresh Listing</a>
</div>
Why is the template not rendering? Running Ember.TEMPLATES in the console returns all the other view template links intact:
> Ember.TEMPLATES
=> Object {app/templates/gigs/edit: function, app/templates/gigs/event: function, app/templates/gigs/show: function, application: function}
But not the one for list. Why is that template AWOL?
For reference, I am running the following according to the browser console:
Ember.VERSION : 1.0.0-rc.1 ember.js:339
Handlebars.VERSION : 1.0.0-rc.3 ember.js:339
jQuery.VERSION : 1.9.1
-Edit: I have just discovered that including the Handlebars reference to the Event view in index.html.erb causes that template to disappear,too:
<h1>Gigs</h1>
<script type="text/x-handlebars">
{{ view App.ListGigsView }}
</script>
<script type="text/x-handlebars">
{{ view App.EventView }}
</script>
<script type="text/javascript">
$(function() {
App.gigsController.loadAll(<%= #gigs.to_json.html_safe %>);
});
</script>
Why does this happen? And how can I avoid it?
app/templates/ gets stripped from the template name by default. Try gigs/list.
For me it worked when stripping out templates, e.g. app/gigs/list.
This no worky, the onClick handler is removed by Grails when I do a view-source on the HTML output (Grails 1.2.1) What am i missing?
I'm trying to internationalize the confirmation message displayed in the javascript
<g:actionSubmit id="deleteButton" value="Delete" action="deleteActivities" onclick="return confirm(' ${g.message(code="common.confirm.delete", args="['Activity']") } ');"/>
Try to use it as follows:
<g:actionSubmit id="deleteButton" value="Delete" action="deleteActivities" onclick="return confirm(' ${message(code: "common.confirm.delete", args: ['Activity'])} ');"/>
I have a regexp in my cucumber test set up for
Then /I should see "(.*)" before "(.*)"/ do |string1, string2|
and in the following statement I say
page.body.should =~ regexp
where my regexp is
regexp = /#{string1}.*#{string2}/m
This is the scenario
Scenario: sort movies alphabetically
When I follow "Movie Title"
Then I should see "2001: A Space Odyssey" before "Aladdin"
But when I run the test I receive this error
expected: /2001: A Space Odyssey.*Aladdin/m
got: "<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<title>Rotten Potatoes!</title>\n<link href=\"/assets/application.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\">\n<script src=\"/assets/application.js\" type=\"text/javascript\"></script>\n</head>\n<body>\n<h1 class=\"title\">Rotten Potatoes!</h1>\n<div id=\"main\">\n<h1>All Movies</h1>\n<form accept-charset=\"UTF-8\" action=\"/movies\" id=\"ratings_form\" method=\"get\">\n<div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\"></div>\n<input id=\"title_sort\" name=\"title_sort\" type=\"hidden\" value=\"true\">\n\nInclude:\nG\n<input id=\"ratings_G\" name=\"ratings[G]\" type=\"checkbox\" value=\"1\">\nPG\n<input id=\"ratings_PG\" name=\"ratings[PG]\" type=\"checkbox\" value=\"1\">\nPG-13\n<input id=\"ratings_PG-13\" name=\"ratings[PG-13]\" type=\"checkbox\" value=\"1\">\nNC-17\n<input id=\"ratings_NC-17\" name=\"ratings[NC-17]\" type=\"checkbox\" value=\"1\">\nR\n<input id=\"ratings_R\" name=\"ratings[R]\" type=\"checkbox\" value=\"1\"><input id=\"ratings_submit\" name=\"commit\" type=\"submit\" value=\"Refresh\">\n</form>\n\n<table id=\"movies\">\n<thead><tr>\n<th class=\"hilite\">Movie Title</th>\n<th>Rating</th>\n<th>Release Date</th>\n<th>More Info</th>\n</tr></thead>\n<tbody id=\"movielist\"></tbody>\n</table>\nAdd new movie\n\n</div>\n</body>\n</html>\n" (using =~)
Diff:
## -1,2 +1,44 ##
-/2001: A Space Odyssey.*Aladdin/m
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Rotten Potatoes!</title>
+<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css">
+<script src="/assets/application.js" type="text/javascript"></script>
+</head>
+<body>
+<h1 class="title">Rotten Potatoes!</h1>
+<div id="main">
+<h1>All Movies</h1>
+<form accept-charset="UTF-8" action="/movies" id="ratings_form" method="get">
+<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
+<input id="title_sort" name="title_sort" type="hidden" value="true">
+
+Include:
+G
+<input id="ratings_G" name="ratings[G]" type="checkbox" value="1">
+PG
+<input id="ratings_PG" name="ratings[PG]" type="checkbox" value="1">
+PG-13
+<input id="ratings_PG-13" name="ratings[PG-13]" type="checkbox" value="1">
+NC-17
+<input id="ratings_NC-17" name="ratings[NC-17]" type="checkbox" value="1">
+R
+<input id="ratings_R" name="ratings[R]" type="checkbox" value="1"><input id="ratings_submit" name="commit" type="submit" value="Refresh">
+</form>
+
+<table id="movies">
+<thead><tr>
+<th class="hilite">Movie Title</th>
+<th>Rating</th>
+<th>Release Date</th>
+<th>More Info</th>
+</tr></thead>
+<tbody id="movielist"></tbody>
+</table>
+Add new movie
+
+</div>
+</body>
+</html>
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/movie_steps.rb:33:in `/I should see "(.*)" before "(.*)"/'
features/sort_movie_list.feature:26:in `Then I should see "2001: A Space Odyssey" before "Aladdin"'
Any suggestions? I'm assuming my error is in my regexp but I cannot find a working solution.
ok, glad to have helped! Answering so I can get the Stack overflow karma... Either your template needs to list the movies or your scenario needs to populate the data you are looking for.