I am wondering whether it's possible to add new values on the fly to a chosen.js multiselect (similar to how tagging works).
I've seen in another SO post a user saying this is possible. He links to an example and a fork on github, but I've had some difficulties implementing those.
The source code is written in CoffeeScript. I've tried compiling it (using an online compiler) to regular JavaScript, copy pasted the code into a blank test project but I got errors. After that, I've loaded The AbstractChosen and SelectParser as well (compiled them to js) and didn't get errors, but the 'add items on the fly' functionality is not there (although i initialized the chosen described in the aforementioned link).
Has anybody worked with this fork? If yes, could you please share your experiences with it?
The problem you have is because you haven't follow the steps in the documentation:
If you download the source, install the correct packages and run the build commands you end with a chosen.jquery.js, chosen.proto.js and chosen.css.
So the following steps should do it for you:
Download: https://github.com/koenpunt/chosen/archive/option_adding.zip
Install packages: npm install && gem install bundler && bundle install
Run build: grunt build (note, for this you'll need the grunt cli)
Edit
Or for your convenience, download a compiled release.
the documentation mentions this option:
Updating Chosen Dynamically
If you need to update the options in your select field and want Chosen
to pick up the changes, you'll need to trigger the "chosen:updated"
event on the field. Chosen will re-build itself based on the updated
content.
with this.
$("#form_field").trigger("chosen:updated");
This can be combined with
// Add field
$("#form_field").append("<option>Utopia</option>");
$("#form_field").trigger("chosen:updated");
Adding this together to an example can be found at the jsfiddle:
http://jsfiddle.net/E5X9x/
The solution is here
$('select').chosen({plugins: ['option-adding']});
or
$(function() {
$(".chzn-select").chosen({
create_option: true,
// persistent_create_option decides if you can add any term, even if part
// of the term is also found, or only unique, not overlapping terms
persistent_create_option: true,
// with the skip_no_results option you can disable the 'No results match..'
// message, which is somewhat redundant when option adding is enabled
skip_no_results: true
});
});
Related
I may be overthinking, but whenever something appears different, I try to get return it to the state it was. I ran ng new in my terminal and created a new Angular Project. However, instead of the normal off-white colors in the explorer
I am receiving a multi-color file listing
When I hover over the (M) or (A) I receive a message saying (Modified) and (Index Added) respectively. I do not know what consequences this could have further down my project, and any help would be appreciated. I have search StackOverflow and all other sites for answers, but have come up empty!
It allows you to view git status of your project and was included in version 1.18 update.
If you want to disable it, go to File -> Preferences->settings.
Set:
git.decorations.enabled:false
in your user/workspace settings.
It does not have any effect in your project itself.
I'm having a couple of issues with my upgrade from 4.1 to 4.4.7:
Existing custom addons no longer work. I'm getting a JavaScript error
on the following call in my init function, for example:
CKEDITOR.plugins.add( 'pdf',
{
lang: 'de,en,es,fr,fr-ca',
init : function( editor )
{
editor.addCommand( 'pdf', new CKEDITOR.dialogCommand( 'pdf' ) );
.
.
.
It no longer appears to recognize addCommand as a valid method.
After removing all plugins, I am able to get the editor to appear, however, my menus have disappeared.
Is there a clear upgrade path from 4.1 to the current version, or at least a list of deprecated methods? I haven't been able to locate it.
Thanks.
You should probably at least scan the changelog. Breaking changes are always explained there.
Do remember you are trying to incorporate over 2 years of active development into your customized editor. There were lots of new features introduced during this time, so your plugins may need some serious adjustments.
As for particular methods, just check the API. Information such as whether something is deprecated or examples how it should be implemented will be there (example: editor.addCommand).
As for building custom plugins, check the plugin tutorials for some working code and explanations. The source codes are available on GitHub.
Last but not least, remember to clear the browser cache after changing any JavaScript/CSS files. This usually solves most issues with toolbar/menus etc. disappearing after an upgrade or configuration change.
I am using Gulp to create a bunch of tasks for a project I have and when you type gulp I would like to show some instructions on the terminal to show people the commands they can Run and what they do.
I didn't want to use console.log because it blends in and I wanted to give bolds and styles to the lettering.
I was searching for a way to do that but I couldn't find any that worked properly, does anyone know?
Examples of people that have this is Yeoman and Foundation for Apps CLI
If you need to avoid using console.log you can use the underlying standard output, accessible in node through process.stdout
https://nodejs.org/api/process.html#process_process_stdout
The example provided in that link is the actual definition of console.log in node:
console.log = function(d) {
process.stdout.write(d + '\n');
};
For colouring and styling your strings you could use cli-color or chalk.
you can either use gulp-help, which gives you ability to provided even details to be printed for a given task... or use gulp-task-linking which prints tasks as main tasks & sub-tasks
visit the link to know all the options that they provide...
Not sure when this started happening, but now my intellisense auto-completion is suggesting and using "Function (in DHtml.js, ...)" when I need it to be "function" while working in .js files.
How do I configure this option?
This appears to be fixed in the 8.2 EAP builds - http://youtrack.jetbrains.com/issue/RSRP-400812 (note that ticket says fixed in build 8.1.1000. That build isn't 8.1, and isn't available - it's been replaced by 8.2). Please can you try the EAP build and see if it fixes the problem? If not, please update the YouTrack ticket.
If you don't want to use the EAP build, I think you can work around the issue by clearing the solution's cache (ReSharper -> Options -> General -> Clear cache). As I understand it, the reason you're getting Function instead of function is due to ReSharper tracking selected items and giving previously selected items preference. Clearing the cache clears the tracked values and should allow you to use function again, but you might encounter the issue again at a later date.
Can anyone tell me what execCommand commands are available in CKEditor?
Like editor.execCommand('bold')
The commands that are available to you depend on the installed plugins.
This list of available CKEditor commands can be found using CKEDITOR.instances.editor1.commands
Unfortunately commands are not specified in JSDocs.
However, every command is added to editor by editor#addCommand method, so you can grep the code for them:
> grep -R addCommand *
Regarding Daevo's response - toolbar config consists of buttons names - not command names. Usually each button has corresponding command, but it doesn't have to be a rule.
Tnnks for ur rply..Is there any command to select particular text..?
There are three commands related to selection - "selectAll", "selectNextCell", "selectPreviousCell". But if you want to do custom selection take a look on Range and Selection APIs. In short - you have to create range and call range#select method.
They can be any command. This would include all the built-in command like listed here http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar
Addionally and commands you or a plug-in create.
I guess the main point is to allow you to call afterCommandExec and beforeCommandExec so you can perform your own code when a button is clicked.