|
I'm gonna abandon this idea.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
jkirkerx wrote: var mFrame = document.getElementById('mainFrame'); is looking for mainframe in the current (subframed) document, so won't find it there. You need to go up a level, since the IFRAME called mainframe is in the top-level document:
var mFrame = window.top.document.getElementById('mainframe'); (Haven't tested that but I think it's right - should put you on the right track anyway).
|
|
|
|
|
But I get the idea. Climb up a level out of the child frame first.
Thanks, will play around with it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hey,
I am trying to implement a virtual populate in my js between two models I created.
reviewModel:
const reviewSchema = new mongoose.Schema({
review: {
type: String,
required: [true, 'Review can not be empty!']
},
rating: {
type: Number,
min: 1,
max: 5
},
createdAt: {
type: Date,
default: Date.now(),
},
tour: [
{
type: mongoose.Schema.ObjectId,
ref: 'Tour',
required: [true, 'Review must be belong to a tour.']
}
],
user: [
{
type: mongoose.Schema.ObjectId,
ref: 'User',
required: [true, 'Review must be belong to a user.']
}
]
},
{
toJSON: { virtuals: true },
toObject: { virtuals: true },
}
);
and my tourModel:
const tourSchema = new mongoose.Schema({
name: {
type: String,
required: [true, 'A tour must have a name'],
unique: true,
trim: true,
maxlength: [40, 'A tour name must have less or equal then 40 characters'],
minlength: [10, 'A tour name must have at least 10 character']
},
slug: {
type: String
},
duration: {
type: Number,
required: [true, 'A tour must have a duration']
},
maxGroupSize: {
type: Number,
required: [true, 'A tour must have a group size']
},
difficulty: {
type: String,
required: [true, 'A tour must have a difficuulty level'],
enum: {
values: ['easy', 'medium', 'difficult'],
message: 'Difficulty is either "easy", "medium" or "difficult"'
}
},
ratingsAverage: {
type: Number,
default: 4.5,
min: [1, 'Rating must be above 1'],
max: [5, 'Rating must be below 5']
},
ratingsQuantaity: {
type: Number,
default: 0
},
price: {
type: Number,
required: [true, 'A tour must have a price']
},
priceDiscount: {
type: Number,
validate: {
validator: function (val) {
return val < this.price;
},
message: 'Discount price ({VALUE}) shoulld be below the regular price'
}
},
summary: {
type: String,
trim: true,
},
description: {
type: String,
trim: true,
required: [true, 'A tour must have a description']
},
imageCover: {
type: String,
required: [true, 'A tour must have a image cover']
},
images: [String],
createdAt: {
type: Date,
default: Date.now(),
select: false
},
startDates: [Date],
secretTour: {
type: Boolean,
default: false
},
startLocation: {
type: {
type: String,
default: 'Point',
enum: ['Point']
},
coordinates: [Number],
address: String,
description: String
},
locations: [
{
type: {
type: String,
default: 'Point',
enum: ['Point']
},
coordinates: [Number],
address: String,
description: String,
day: Number
}
],
guides: [
{
type: mongoose.Schema.ObjectId,
ref: 'User'
}
]
},
{
toJSON: { virtuals: true },
toObject: { virtuals: true }
}
);
in tour model I virtual true for JSON and Object as you can see.
i want to use them to populate tour from review using the id:
tourSchema.virtual('reviews', {
ref: 'review',
foreignField: 'tour',
localField: '_id'
});
I tried to go to mongoose documentation and everything seems to be fine in the virtual function but it doesn't work and i can't see the reviews on the tour when I use the route for seeing tour by id (can't see review field).
|
|
|
|
|
input component in ember as below:
{{#each tags as |tag index|~}}
<li class="emberTagInput-tag">
{{yield tag}}
{{#if _isRemoveButtonVisible}}
<a class="emberTagInput-remove" {{action 'removeTag' index}}></a>
{{/if}}
</li>
{{~/each~}}
<li class="emberTagInput-new">
{{masked-input
disabled=readOnly
class=(concat 'emberTagInput-input js-ember-tag-input-new' (if readOnly ' is-disabled'))
maxlength='20'
textMaxLength='20'
placeholder=placeholder
input-format='regex'
input-filter='[A-Za-z0-9\ \-@#]{1,20}'
input-filter-message='Complaint Id is not valid.'
}}
</li>
And I am using it in my hbs files as below:
<div class="col-md-2">
<div class="form-group">
<label for="due-date" class=" control-label">Complaint Id</label>
{{#tag-input
maxlength=20
tags=tags
addTag=(action 'addNewTag')
removeTagAtIndex=(action 'removeTagAtIndex')
as |tag|
}}
{{tag}}
{{/tag-input}}
</div>
</div>
I want to set max length for the input that I enter as text in the textbox that comes with this component, any help please which property sets the max length that one can enter in it? Thanks a lot please.
|
|
|
|
|
I see you have several attempts. Are they not working?
Built-in Components - Components - Ember Guides[^]
It's the standard maxlength attribute.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I am using an masked-input field as below:
{{masked-input
mask='********************'
disabled=readOnly
class=(concat 'emberTagInput-input js-ember-tag-input-new' (if readOnly ' is-disabled'))
maxlength=maxlength
placeholder=placeholder
value=model.Address.AltPhone
input-format='regex'
input-filter='[A-Za-z0-9 \-_@#]{1,20}'
input-filter-message='Complaint Id is not valid.'
maxlength="20"
}}
I want to allow all Alphanumeric values with only few special characters -, _, @, #, I don't want to allow other special characters, can somebody please help me what should be the mask value for it. Can somebody please help me in this regards, thanks in advance.
|
|
|
|
|
Make life easier for yourself:
Create an onkeyup and onchange event for your input control.
Create the function target for the events
Inside function: use regex (regular expressions) to parse/cleaning 'value' from control.
update control value with result.
You can also handle the length, as well, truncating to whatever size you wish (a function arg?).
A plain javascript function will be useful for more controls - you could avoid the overhead of creating the template.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I have tried by putting the input-filter as below:
input-filter='[A-Za-z0-9 \-_@#]{1,20}', it is accepting all the Alpha Numeric values but not allowing the 3 special characters that I want it to allow: -,@,#, can you please help me in this regards.
If mouse functions are better, can you please give me an example here - thanks in advance my friend.
|
|
|
|
|
OK - lets go about this analytically:
It works for A-Za-z0-9
Now add just one of your special characters at a time and see which, if any work - or what we're really looking for - is which one is breaking your string.
Note, also, that shortcuts exist for standard numeric and alpha ranges:
[^] And, if I read it correctly, '\w' is the equivalent of '0-9A-Za-z' and the do mention the hyphen character, as well.
- \d – is the same as [0-9]
- \w – is the same as [a-zA-Z0-9_],
- \s – is the same as [\t\n\v\f\r ], plus few other rare unicode space characters.
Comes from that page.
Find out the character that's killing you. It will help you remember three things (1) how to hunt for the problem (2) when you find the bad actor(s), why they're bad, (3) burn it into your mind so it is not only remembered but parallel problems are identified in advance.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
OK I have written a function for onKeyUp, as below, but what I want is to remove those special characters that are not from the 3 in the above list -, @, #.
Can you please modify the function how can I remove them automatically? Or suggest me for something. Thanks in advance my friend,
JS function:
forTest(e) {
e = 'some test';
},
Ember Control (html input-tag control):
{{#tag-input
tags=tags
addTag=(action 'addTag')
onKeyUp=(action 'forTest')
removeTagAtIndex=(action 'removeTagAtIndex')
as |tag|
}}
{{tag}}
{{/tag-input}}
|
|
|
|
|
1) Whatever ember-control is, I don't use it. I use straight javaScript, no "frameworks".
2) Did you try, as I suggested yesterday, eliminating some of your special characters from your regex expression and see which of them work as expected? You didn't say.
OK - why I send you into this direction: I use php/javaScript/SQL all in the same page, which is often a generated page. It can absolutely not work on the basis of improperly handled nested single and double quotes - which only co-exist on the final page and it's occasionally not what one expects. Unless it sticks out in an obvious way (good luck) I need to roll back parts of the page creation until it works and then I have a point to look for what's not phased correctly.
You are in a similar situation: plain alpha-numeric filtering works. Your entire regex expression, however, does not. Do it piece by piece: only the alpha-numeric and then add one of your special characters. If it works, add another. If it fails - try another (not add to a failed version), which hopefully will now work without the know failure-causing character. For that matter, you may even wish to try just reversing the order of your special characters near the end of your regex expression.
But you've not told me what you have tried to uncover the problem - I want to teach you how to do this; much more valuable than the expression, itself.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Yes I tried, its the mask value, which I am setting as mask='********************' is not allowing me to enter any special characters, if I remove it, its allowing all the characters and without limit.
Yes my exposure to JavaScript and Frameworks is limited, I am not able to find solution.
If I remove mask='********************', its not only allowing me all characters but unlimited number of characters, even if I try to set the max length property to 20 - need some help, thank you.
|
|
|
|
|
Get rid of the template!
In the same function where you use the regex expression to clean the string, get the length of the cleaned string and if it's greater than 20 (or whatever value you like) the send back a "Substring" of length 20 as the value.
Simple as that. No annoying masks to worry about for some so simple as a max-length string constraint. If your string's name is 'mystring'
if( mystring.length > 20)
mystring = mystring.substring(0, 20);
It takes some learning, but all the tools you need are already in javaScript.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I have a box composed from 5 images placed over each other to create a one picture. So I need to create a pixelated div to make this box pixelated. Because I have 5 images and the color of these images can be changed dynamically so I can't solve this problem using canvas. Any solution, idea, please!!
|
|
|
|
|
HTML:
<div class="tag-container" id="tag-container">
tag1tag2tag3
</div>
<input type="text" value="" placeholder="Add a tag" id="add-tag-input" />
jQuery:
$(document).ready(function(){
$(function(){
$("#add-tag-input").on({
focusout : function() {
var txt = this.value.replace(/[^a-z0-9\+\-\.\#]/ig,'');
if(txt) $("<span/>", {text:txt.toLowerCase(), appendTo:"#tag-container", class:"dashfolio-tag"});
this.value = "";
},
keyup : function(ev) {
if(/(188|13)/.test(ev.which)) $(this).focusout();
}
});
$('.tag-container').on('click', 'span', function() {
if(confirm("Remove "+ $(this).text() +"?")) $(this).remove();
});
});
}); And CSS:
.tag-container {
max-width: 300px;
}
.dashfolio-tag {
cursor:pointer;
background-color: blue;
padding: 5px 10px 5px 10px;
display: inline-block;
margin-top: 3px;
color:#fff;
margin-right: 4px;
background:#789;
padding-right: 20px;
}
.dashfolio-tag:hover{
opacity:0.7;
}
.dashfolio-tag:after {
position:absolute;
content:"×";
padding:2px 2px;
margin-left:2px;
font-size:11px;
}
#add-tag-input {
background:#eee;
border:0;
margin:6px 6px 6px 0px ;
padding:5px;
width:auto;
}
We are using less, instead of CSS, can you please help in converting the above code into Ember JS
|
|
|
|
|
I suggest you describe where you are stuck. Asking someone to do all the work for you will not likely get you any help.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I did resolve it buddy, here it is:
{{#tag-input
tags=tags
addTag=(action 'addTag')
removeTagAtIndex=(action 'removeTagAtIndex')
as |tag|
}}
{{tag}}
{{/tag-input}}
|
|
|
|
|
const base = [
{id: 1,name: 'A1'}, {id: 11,name: 'A11'},
{id: 12,name: 'A2'}, {id: 111,name: 'A111'},
{id: 112,name: 'A112'}, {id: 121,name: 'A121'},
{id: 122,name: 'A122'},
{id: 2,name: 'A2'},{id: 3,name: 'A3'},{id: 4,name: 'A4'}
];
const tree = [
{id: 1, parent:0, level: 'L1'},
{id: 11, parent:1, level: 'L2'},
{id: 111, parent:11, level: 'L3'},
{id: 112, parent:11, level: 'L3'},
{id: 12, parent:1, level: 'L2'},
{id: 121, parent:12, level: 'L3'},
{id: 122, parent:12, level: 'L3'},
]
i have two object one is base another one is tree. if i pass the 'id=11' it has to remove the [id:11]'s level 'L2' and its top level 'L1' id from the base object and result the remaining values. the below result am expecting
const result = [
{id: 111,name: 'A111'},
{id: 112,name: 'A112'}, {id: 121,name: 'A121'},
{id: 122,name: 'A122'},
{id: 2,name: 'A2'},{id: 3,name: 'A3'},{id: 4,name: 'A4'}
];
how to achieve this?
modified 5-Sep-20 13:11pm.
|
|
|
|
|
Hi,
Tried so many things and nothing works.
It works in Edge but not in IE, is it possible at all?
Tried a lot of combination as suggested (location.href and window.location.href, replace etc.).
IE settings for redirection were allowed by default.
This was the last try:
if(!!navigator.userAgent.match(/Trident.*rv\:11\./))
{
window.location.href = "https://google.de";
window.location.reload();
}
modified 2-Sep-20 7:25am.
|
|
|
|
|
Just setting the location.href or using location.assign should work fine.
location.href = "https://google.de";
location.assign("https://google.de"); Location: href - Web APIs | MDN[^]
Location: assign() - Web APIs | MDN[^]
NB: Call one or the other, not both. And don't call reload afterwards, since that reloads the current page.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
that's weird. It doesn't work. I tested it in my IE (V 11.1016.18362.0) on my Windows 10 PC.
Could anybody confirm that it works in his IE?
I don't know how else to test it as in my browser.
modified 4-Sep-20 6:28am.
|
|
|
|
|
It's solved.
Had an Error Code caused by UrlSearchParam(?!). It prevented the website in IE to run the rest of the code. Thanks all.
|
|
|
|
|
|
I'm executing a function on onclientclick.
function GetUrlPage() {
var pplid = document.getElementById('<%= tbPersonId.ClientID %>').value;
var newwindow = window.open('MXUrl.aspx?PersonId=' + pplid, null,
"Width=475px, Height=500px; top=42px; scrollbars=1; toolbar=0; titlebar=0; menubar=0; status ;");
Nothing happens. If I add an alert("some message"); after the window.open everything works great.
I can only assume it is just blowing thru the code but I don't know how to make it wait.
Don't do much in javascript so am really at a loss. Really appreciate any help you can give me.
|
|
|
|
|