How to disable the ability to search - tom-select

Easiest question ever, I looked at the documentation but can't find the answer. Is there an option to disable the ability to search when clicking the select?
Thanks!

as I'm not allowed to add a comment here is the answer:
https://tom-select.js.org/docs/#controlinput
when you set controlInput: null the search input will disappear.
Hope this helps someone else.

I am not sure but if you set search field to null the search will not work any more.
var control = new TomSelect('#select-tools',{
maxItems: null,
valueField: 'id',
labelField: 'title',
searchField: null, //<------------ HERE
options: [
{id: 1, title: 'Spectrometer', url: 'http://en.wikipedia.org/wiki/Spectrometers'},
{id: 2, title: 'Star Chart', url: 'http://en.wikipedia.org/wiki/Star_chart'},
{id: 3, title: 'Electrical Tape', url: 'http://en.wikipedia.org/wiki/Electrical_tape'}
],
create: false
});

Related

Custom buttons in tinyMCE 6.x to insert custom html

I have what I want working in tinyMCE v4.x, but am really styruggling to update the code to work with the latest version (6.x) of this editor.
Basically, my custom button opens a new (popup) window (passing various arguments) in which the user can do various things which produces some HTML, and this is then pasted back into the tinyMCE editor window (at the current insertion point) via editor.insertContent([whatever]);
Here's my v4 code to add the button to the editor toolbar:
editor.addButton('myButton', {
text: 'XYZ',
tooltip: 'Do something',
icon: false,
onclick: function () {
editor.windowManager.open({
title: 'XYZ',
url: 'mypopuppage.html',
width: 800,
height: 600
}, {
arg0: '0',
arg1: '1',
arg2: editor.selection.getContent({ format: 'html' }),
arg3: '',
arg4: ''
});
}
});
});
As I say, this is fine - it works. For v6 I've tried, but can't get it to work. I have not managed to find any code examples online that do anything similar for tinyMCE v6.x, though I'm sure there must be some... this is my effort, but clearly requires more, as it doesn;t work - the button shows, but nothing happens when I click it:
selector: "textarea#txtA",
menubar: false,
statusbar: false,
plugins: "myButton",
setup: (editor) => {
editor.ui.registry.addButton('myButton', {
text: 'XYZ',
onAction: (_) => {
editor.windowManager.open({
title: 'XYZ',
url: 'mypopuppage.html',
width: 800,
height: 600
}, {
arg0: '0',
arg1: '1',
arg2: editor.selection.getContent({ format: 'html' }),
arg3: '',
arg4: ''
});
}
});
},
toolbar1: "myButton"
});
Any help gratefully received...
[edit] OK - getting there; silly me: I should use
editor.windowManager.openUrl({
to open the dialog... now I just have to figure out how to send the HTML back to the editor...
..not sure I'm passing my arguments corectly for this version of tinyMCE... or not reading them correctly on the popup page. In v4x I could use
var args = top.tinymce.activeEditor.windowManager.getParams();
but this doesn't seem to work with v6x... I can use a workaorund of passing the arguments as parameters in the URL I call, but I suspect there is a more robust way of doing it as per v4x - damned if I can find it though... that asied, I'm just about there now :)

Can't change the pagination 'next' and 'prev' labels to my language in grid.js

There is no such option as change the prev and next button label in the documentation, and when i try to use string replacement or change the button innerHTML via Javascript, it doesn't work, is there any way that I can safely change the label?
You can use the language config (added since v1.5.0) to customize this:
new Grid({
columns: ['Name', 'Email', 'Title'],
sort: true,
search: true,
pagination: {
limit: 5
},
data: Array(50).fill().map(x => [
faker.name.findName(),
faker.internet.email(),
faker.name.title(),
]),
language: {
'search': {
'placeholder': '🔍 Search...'
},
'pagination': {
'previous': '⬅️',
'next': '➡️',
'showing': '😃 Displaying'
}
}
});
Also see this example: https://gridjs.io/docs/examples/i18n/

How to disable specific options in a select in Groovy Server Pages (gsp)

I have the below select tag in my gsp which is working fine.
<q:select id="myItem"
name="myItem"
from="${items}"
optionKey="id"
value="${item?.id}"
optionValue="${{it?.name)}}"
noSelection="${['': '']}" />
But I need to disable couple of options within the select based on its status attribute.
items = [{
id: 1,
name: 'test',
status: 'available'
},
{
id: 2,
name: 'john',
status: 'booked'
},
{
id: 3,
name: 'sans',
status: 'available'
}];
I want the option item with status booked to be shown as readonly or disabled. How to achieve this.
You just need to add an optionDisabled attribute like:
optionDisabled="${{it?.status == 'booked'}}
to your <g:select>.
EDIT: for anyone coming to this later, note #HansMaulwurf comment below noting that you'll need to use optionKey as well.

About the "body" parameter for tinymce's "windowManager.open" method

I'm looking at this example w.r.t creating tinyMCE plugin. What I want to do is to open
a popup, and the content inside the popup is specified programmatically, without having to load a physical page at certain url:
Add an input element of type=file in tinymce container
Basically the author solved the issue about a plugin he was trying to create. I'm trying the same code but the popup is completely empty for me, no errors, any suggestions? Where can I find info about the "body" parameter when calling "windowManager.open", like:
// Open window
editor.windowManager.open({
title: 'Example plugin',
body: [{
type: 'textbox',
name: 'code',
label: 'Video code'
}],
...
Try giving the textbox a size:
// Open window
editor.windowManager.open(
{title: 'Example plugin',
body: [
{ type: 'textbox',
size: 40,
name: 'code',
label: 'Video code'
}
],
.....

MongoDB, add new { field : value } in existing embedded document with multiple level dot notation?

What I am trying to do is add a new {field:value} for a blog post. So for example, if I wanted to start tracking impressions on websites.blog_posts.url: 'http://www.example.com/01.html' how can I add that impressions attribute for that blog post?
My current document structure:
{
email_address: 'webmaster#example.com',
password: 'random_password',
first_name: 'John',
last_name: 'Doe',
user_type: 'WEBMASTER',
newsletter: 'NO',
websites: [{
main_title: 'My Blog Website',
main_url: 'http://www.example.com',
blog_posts: [{
url: 'http://www.example.com/01.html',
title:'My first blog post',
description: 'My first description.'
}, {
url: 'http://www.example.com/02.html',
title: 'My second blog post',
description: 'My second description.'
}, {
url: 'http://www.example.com/03.html',
title: 'My third blog post',
description: 'My third description.'
}, {
url: 'http://www.example.com/04.html',
title: 'My fourth blog post',
description: 'My fourth description.'
}]
}]
}
Here is what I thought would work using update and making upsert TRUE.
db.my_collection.update( {'websites.blog_posts.url': 'http://www.example.com/01.html' }, {'$set': {'websites.blog_posts.impressions': 549}}, true )
The error that I received is:
*can't append to array using string field name [blog_posts]*
Maybe "$set" is not correct for this or maybe I can not reference that deep with dot notation? I just started using MongoDB yesterday, any help would be great.
Thank you!
What you're trying to do is not possible given your schema. Dot-notation can be multi level but if there's more than one level that is an array it can no longer be addressed using the positional operator '$'.
E.g. you'd need to do :
db.my_collection.update(
{'websites.blog_posts.url': 'http://www.example.com/01.html' },
{'$set': {'websites.$.blog_posts.$.impressions': 549}},
true );
But having two position operators in the update is not possible since MongoDB can only determine the position of an element in the first array.
Your only option is to redesign your schema to have a dedicated collection of user websites (which is better for other reasons too in this case).