Bootstrap3 Typeahead - Empty message [closed] - typeahead

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I didn't understand how to make it appear the "empty" message in bootstrap3 typeahead. I am using the custom template but what value must be assigned to source to make it appear?
Here is my code (not working):
<script>
function doSomething() {
var states = [];
$("#test").typeahead({
source : states,
minLength: 3,
templates: {
empty: ['<div>',
'No Items Found',
'</div>'
].join('\n')
}
});
}
</script>
[...]
<body onLoad="doSomething();">
<input class="typeahead" type="text" id="test">
</body>

I confused typeahead (https://github.com/twitter/typeahead.js) with bootstrap3 typeahead (https://github.com/bassjobsen/Bootstrap-3-Typeahead).
The question is wrong because the code above is correct for https://github.com/twitter/typeahead.js, instead I had included https://github.com/bassjobsen/Bootstrap-3-Typeahead, which is a different library and have different options.

Related

Flask-Admin - what to pass in url_for(' ')? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I got an error, that says, that no URL can be build from that parameter inside url_for('').
I passed url_for('admin') but that does not work. What should I pass to get to localhost:5000/admin ?
Thank you
You pass the name of the definition of the route you want to visit.
For example:
#app.route('/')
def index():
return 'Hello, World!'
...
#app.route('/some_page')
def somewhere_else():
if something_happened:
redirect(url_for('index'))
return render_template('some_page.html')
Or if you are using it inside your HTML:
<a href="{{ url_for('index') }} ...></a>

I'm pulling a dictionary from an API call, when I pull URL information it quotes and brackets around them [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I'm pulling the website information using a call in my Django template. All the information is getting pulled, but when I pull the website it has quotes and brackets around it like '[https://xxxxx.org]' obviously when I create the <a href=>{{ web.site }}</a> tag around it, it can't browse to the site.
Is there a quick way to strip off all the extra '[]' around the URL?
I figured it out, those were all good ideas, but what was happening was I was pulling from a dictionary with an embedded list.
'data': {
'BTC': {
'urls': {
'website': ['https://bitcoin.org/'],
'technical_doc': ['https://bitcoin.org/bitcoin.pdf'],
'twitter': [],
'source_code': ['https://github.com/bitcoin/']},
'logo': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1.png',
'id': 1,
'name': 'Bitcoin',
'symbol': 'BTC',
I was only accessing up to the dictionary item:
{{ data.BTC.urls.technical_doc }}
Which was returning the list:
['https://bitcoin.org/bitcoin.pdf']
To get the item I wanted inside the list, I had to add a "0" at the end to snatch out that list item:
{{ data.BTC.urls.technical_doc.0 }}
Which in turn pulled the item out of the list clean.
https://bitcoin.org/bitcoin.pdf
Thanks for everyone's help, but it was my own misunderstanding.
i think this is what you need:
string.strip
string = "'[https://xxxxx.org]'"
# strip: Remove specific characters at the beginning and at the end of the string
print(string.strip("'[]"))
# Output: https://xxxxx.org

Django: How to populate value into form template? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have created a small form which includes something like name, mobile number, age field. All are text fields.
These values are stored in DB.
I want my template to pre-populate the form with values from DB (if exists). How can this be done?
My template code is as below:
<div>
<center><form action="/profilesettings/" method="post" enctype="multipart/form-data">{% csrf_token %}
{{form.as_p}}
<input type="submit" value="submit">
</form></center></div>
Currently, it displays form with empty field. Instead of empty fields, I would like them to show values which are fetched from DB.
check this example on django docs
article = Article.objects.get(pk=1)
article.headline
'My headline'
form = ArticleForm(instance=article)
form['headline'].value()
'Initial headline'

HTML5 - simple pattern don't works with Smarty [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm using a simple pattern like this :
<input type="text" pattern="[a-z]{2}" required ../>
But it's never valid. It seems it didn't works.
I tested it in Firefox
Is there something to active or something like that ?
My template :
<section class="inscription">
<h1>Inscription</h1>
<form method="post" enctype="multipart/form-data">
<div class="formu-inscription">
<label for="nom"> Nom : </label> <br/><input type="text" id="nom" name="nom" value="{set_value('nom')}" pattern="[a-z]{2}" required /> <br />
{form_error('nom')}
/* others inputs */
For people using smarty template, you can do
pattern="[a-z]{literal}{2}{/literal}"
Looking at the rendered source code you posted as a comment on a now deleted answer you have
<input type="text" id="nom" name="nom" value="" pattern="[a-z]2" required />
This is not the pattern in your source that you posted in your question. It seems that you are using some unspecified templating system that is using the {} characters as field identifiers and is misinterpreting your pattern.
The result in your rendered page is the pattern [a-z]2, which will validate for a string like a2 or f2, but not a, or aa, a3 or anything longer.
Since you haven't specified what templating system you're using it's not possible to indicate how you might work around this. Possibly a pattern of [a-z]{{2}} might work.

ColdFusion - how to edit a record? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to edit the Record2 but when I click the Edit button it always display the info of Record1. If I click any other Edit buttons it only display the info of Record1. How does it know which record I want to edit? Please help. Thank you.
<cfform name="formName" action="edit.cfm" method="post">
....some additional codes.....
<cfloop query="qryName">
Record1_data Edit button
Record2_data Edit button
Record3_data Edit button
Record4_data Edit button
</cfloop>
....some additional codes.....
</cfform>
Unless there's a really good reason I'd really shy away from using cfform there's rarely a good reason to use it
You need to pass in some sort of form variable that has the corresponding ID to what you're pulling into the database.
<form name="formName" action="edit.cfm" method="post">
<cfloop query="qryName">
<input type="checkbox" name="Record" value="#qryName.ID#" /> Record #qryName.ID#
</cfloop>
</form>