How set class to input on error using jQuery-validation-engine - jquery-validation-engine

I'm using the jquery-validation-engine plugin and after validate I need to add a class to the inputs with the error promt to add for example a red border or something like that, is there a way using the plugin configuration to setup this?

I alsow use that same plugin.
Do you have the last verion off the plug-in ?
In the file: jquery.validationEngine.js
you will find almost at the bottom:
InvalidFields: [],
onFieldSuccess: false,
onFieldFailure: false,
onSuccess: false,
onFailure: false,
addSuccessCssClassToField: false,
addFailureCssClassToField: false,
These are the 'master' settings for the options you are looking for.
My current setup is like:
InvalidFields: [],
onFieldSuccess: true,
onFieldFailure: true,
onFormSuccess: false,
onFormFailure: false,
addSuccessCssClassToField: 'inputbox-success',
addFailureCssClassToField: 'inputbox-error',
And then the two css classes in youre css file ( 'inputbox-error' & 'inputbox-succes').
This works just fine over here..
Good Luck...
And if you have any more question about this plugin or other functions off it just ask .. :P
Greets,
Marco

Related

guard-minitest runs ALL tests not just the ones for the target file changed

I stripped my Guardfile down to this. If I edit a controller guard starts ALL tests.
guard :minitest, all_on_start: false, all_after_pass: false, spring: true do
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/controllers/#{m[1]}_controller_test.rb" }
end
Am I missing something here?

How to show the find and replace panel with a pre-populated search string?

I know that it is possible to show the Sublime Text "Find and Replace" panel using the show_panel command (either via a keybinding or a plugin), and control which arguments are enabled/disabled.
Example run from Sublime Console panel:
window.run_command('show_panel', { 'panel': 'replace', 'regex': True, 'case_sensitive': False, 'whole_word': False, 'in_selection': False, 'wrap': True, 'highlight': True, 'preserve_case': True })
What I would like to know, is: is there a way to pre-populate the Find What: and Replace With: values?
I found this forum post but it has no reply, and the unofficial documentation is of no help in this case.
I have tried:
'find_what': 'string'
'replace_with': 'string'
'find_history': 'string'
'replace_history': 'string'
'find_history': ['string']
'replace_history': ['string']
'find': 'string'
'replace': 'string'
EDIT: I have also tried:
characters
find_characters
look_for
search_for
find_regex
find_string
search_string
replacement
search_characters
and none of the above makes any difference - the panel is always pre-populated with the previous search and replace values, not what I pass in.
I am aware of the commands slurp_find_string and slurp_replace_string, which will take the current selection and update the Find What / Replace With values respectively, but I would like a way to do it without having to mess around with selections first - I just want to pass the values as arguments directly to the show_panel command.
Does anyone know what parameters/arguments can be used to control this?
You can run an insert command on the window just after you've run the show_panel command.
import sublime_plugin
class ShowPanelPrefilledCommand(sublime_plugin.WindowCommand):
def run(self, interactive=True):
self.window.run_command('show_panel', {
'panel': 'find_in_files',
'where': '<open folders>',
'whole_word': False,
'case_sensitive': False,
'preserve_case': False,
'regex': False,
'use_buffer': False,
'show_context': False,
})
self.window.run_command('insert', {'characters': 'hello'})
if not interactive:
self.window.run_command('find_all', {'close_panel': True})
I wanted to do the same thing for a key binding command that opens a Package Tool and uses the Find Search window. I ended up with something easy to customize and use for any command that just uses another key binding.
After I run my Package Tool, I just use this key binding to insert the text (which is a complicated regex in my case). For me on OSX, it's intuitively remembered as (insert 1) CMD+i, CMD+1
Open Sublime Text / Preferences / Key Bindings
Add this to the User - Default (OS).sublime-keymap
{ "keys": ["super+i", "super+1"], "command": "insert", "args": { "characters": "my-custom-insert-text1" } },
{ "keys": ["super+i", "super+2"], "command": "insert", "args": { "characters": "my-custom-insert-text2" } },
// etc..
This feature was added in Sublime Text build 4123 on 6 December 2021.
The show_panel command for the find and find in files panels can now take "pattern" and "replace_pattern" arguments.

browserify without sourcemaps

I'm using Browserify programmatically, through node, like so:
var options = {
debug: true,
cache: {},
packageCache: {},
fullPaths: true,
noParse: []
};
var b = browserify( 'index.js', options );
b.on('data', customFunction);
b.bundle();
My customFunction doesn't modify the data anyhow, just reads it.
It runs a regex on the first line, to detect the file name of the code that comes on the following lines.
The thing is, when i set options.debug to false, to get rid of the sourcemaps, the customFunction behaves in a very different way (the regex doesn't get half the file names) and i can't seem to figure out the pattern for that difference. I assume that turning debug to false, does more than turning off the sourcemaps.
I just want to turn off the sourcemaps on browserify, with no other side-effects, is this possible?
You could try to extract the source maps with a separate tool like exorcist https://github.com/thlorenz/exorcist

i18next: fallback to [same language + different namespace] instead of [different language + same namespace]

This is about using i18next in a node.js backend.
This is the initialization:
i18next.init({
lng: 'de',
fallbackLng: ['de'],
ns: {
namespaces: ['formal', 'informal'],
defaultNs: 'formal'
},
fallbackToDefaultNS: true,
resStore: {
de: resourcesDE,
en: resourcesEN
}
});
where resourcesDE is an object with structure { formal: { }, informal: { }} and resourcesEN has the same structure but only 'formal', no 'informal' (but I have this problem even if there is 'informal' in resourcesEN).
Now, what I want to have is:
If I request the translation of 'informal:myKey' for English that the search route (== fallback) is:
(en)'informal:myKey' > (en)'myKey' > (de)'informal:myKey' > (de)'myKey'
or
(en)'informal:myKey' > (en)'myKey' > (de)'myKey'
but what actually happens is:
(en)'informal:myKey' > (de)'informal:myKey' > (de)'myKey'
meaning that the language changes before even trying to get a text of the same language from a different (the default) namespace.
How can I achieve this or something along those lines. I've also tried using a context instead of namespaces for these alternatives, but that seemed to behave the same. I'm glad to be proven wrong though.
The solution that worked out for me, in the end:
Instead of namespaces, I use special language flavors: 'de-INFORMAL' and 'en-INFORMAL'. If no label is found under 'en-INFORMAL', the lookup falls back to 'en', first and out of the box. If fallbackLng is set to 'de' it will fallback to that if the label in not found in 'en', either.

i18next init on specific language

I'm using i18next-node for localization of my app.
I have two languages: en-CA and fr-CA
I'm using this to init the app:
i18next.init({
saveMissing: true,
sendMissingTo : 'all',
ignoreRoutes: ['img/','images/', 'public/', 'css/', 'js/'],
debug: true,
lng: 'en-CA'
});
The problem is, when I start the app, it gives me this error:
currentLng set to: en-US
[ { [Error: ENOENT, open 'locales/en-US/translation.json']
errno: 34,
code: 'ENOENT',
path: 'locales/en-US/translation.json' } ]
I don't want en-US, I want en-CA. Now, my app isn't showing either language. How do I set en-CA to be the default?
Turns out you can set fallbackLng : 'en-CA' and that will work. Kind of a hack though.
Try to read the detect language section under http://i18next.com/node/pages/doc_init.html
i18next detects during the request the language from your browser-settings (if not set by any other methode - cookie, querystring). That's why language is set to 'en-US'.
You can set the supported languages on init:
i18n.init({supportedLngs: ['en-CA', 'fr-CA']})
But you still need to set a fallbackLng -> eg. if someone requests your page with language set 'de' some fallback language should be displayed.

Resources