Click here to Skip to main content
14,734,117 members
Home » Discussions » JavaScript
   

JavaScript

 
GeneralRe: How to display a Javascript alert and display a iframe using a javascript dynamic drop-down list Pin
codeguy14-Oct-19 20:42
Membercodeguy14-Oct-19 20:42 
AnswerRe: How to display a Javascript alert and display a iframe using a javascript dynamic drop-down list Pin
ZurdoDev6-Oct-19 9:54
professionalZurdoDev6-Oct-19 9:54 
GeneralRe: How to display a Javascript alert and display a iframe using a javascript dynamic drop-down list Pin
codeguy16-Oct-19 17:00
Membercodeguy16-Oct-19 17:00 
QuestionRe: How to display a Javascript alert and display a iframe using a javascript dynamic drop-down list Pin
ZurdoDev6-Oct-19 17:29
professionalZurdoDev6-Oct-19 17:29 
AnswerRe: How to display a Javascript alert and display a iframe using a javascript dynamic drop-down list Pin
codeguy16-Oct-19 17:47
Membercodeguy16-Oct-19 17:47 
GeneralRe: How to display a Javascript alert and display a iframe using a javascript dynamic drop-down list Pin
phil.o6-Oct-19 22:39
mvephil.o6-Oct-19 22:39 
SuggestionRe: How to display a Javascript alert and display a iframe using a javascript dynamic drop-down list Pin
ZurdoDev7-Oct-19 1:56
professionalZurdoDev7-Oct-19 1:56 
QuestionDouble check if array.find result is not undefined and cancel exception, replace with "" Pin
jkirkerx2-Oct-19 11:33
professionaljkirkerx2-Oct-19 11:33 
So I have this onSubmit function that gathers the data from the form.
Sometimes there is no sub category, or the subcategory has been removed and I haven't written code to update the product subcategory yet. Well I did write code for that but that's another story.

So below, this.model.SubCategoryId =
Then the next line will fail because there is no result with a Key
this.model.SubCategoryId = this.productForm.controls["subCategoryId"].value;
this.model.SubCategory = this.subCategories.find(sc => sc.Value === this.model.SubCategoryId).Key;
I wrote this, well found it on the internet
this.model.SubCategory = this.ensure(this.subCategories.find(sc => sc.Value === this.model.SubCategoryId)).Key;
ensure<T>(argument: T | undefined | null, message: string = "This value was promised to be there."): T {
  if (argument === undefined || argument === null) {
    throw new TypeError(message);
  }
  return argument;
}
I'd like to not throw an error, and return a blank string. Perhaps I'm going about this the wrong way.
One suggested using filter instead of find. I get what the function does, but T is fuzzy to me. Guess it's a generic type in TypeScript. The Type is KeyValue that I made. Perhaps I should change T to KeyValue and return a new KeyValue. hmm...
If it ain't broke don't fix it
Discover my world at jkirkerx.com

AnswerRe: Double check if array.find result is not undefined and cancel exception, replace with "" Pin
jkirkerx2-Oct-19 11:40
professionaljkirkerx2-Oct-19 11:40 
QuestionNot sure where my mistake is. . . I want the two texts to turn blue and yellow. Pin
mattkrebs30-Sep-19 9:38
Membermattkrebs30-Sep-19 9:38 
AnswerRe: Not sure where my mistake is. . . I want the two texts to turn blue and yellow. Pin
Nathan Minier30-Sep-19 10:17
professionalNathan Minier30-Sep-19 10:17 
AnswerRe: Not sure where my mistake is. . . I want the two texts to turn blue and yellow. Pin
Richard Deeming30-Sep-19 11:05
mveRichard Deeming30-Sep-19 11:05 
QuestionImporting css classes into React Component Pin
simpledeveloper26-Sep-19 11:47
Membersimpledeveloper26-Sep-19 11:47 
AnswerRe: Importing css classes into React Component Pin
Richard Deeming27-Sep-19 2:35
mveRichard Deeming27-Sep-19 2:35 
GeneralRe: Importing css classes into React Component Pin
simpledeveloper27-Sep-19 7:09
Membersimpledeveloper27-Sep-19 7:09 
GeneralRe: Importing css classes into React Component Pin
Wishe199130-Sep-19 0:25
MemberWishe199130-Sep-19 0:25 
QuestionTrying to convert a jQuery MVC app into React Web Api App Pin
simpledeveloper26-Sep-19 8:02
Membersimpledeveloper26-Sep-19 8:02 
AnswerRe: Trying to convert a jQuery MVC app into React Web Api App Pin
jkirkerx26-Sep-19 10:18
professionaljkirkerx26-Sep-19 10:18 
GeneralRe: Trying to convert a jQuery MVC app into React Web Api App Pin
simpledeveloper26-Sep-19 10:59
Membersimpledeveloper26-Sep-19 10:59 
GeneralRe: Trying to convert a jQuery MVC app into React Web Api App Pin
simpledeveloper26-Sep-19 11:58
Membersimpledeveloper26-Sep-19 11:58 
AnswerRe: Trying to convert a jQuery MVC app into React Web Api App Pin
Wishe199130-Sep-19 0:20
MemberWishe199130-Sep-19 0:20 
QuestionHow to call Fetch url using HTML ? Pin
Abdalla Ben Omran25-Sep-19 2:53
MemberAbdalla Ben Omran25-Sep-19 2:53 
AnswerRe: How to call Fetch url using HTML ? Pin
Richard Deeming25-Sep-19 3:48
mveRichard Deeming25-Sep-19 3:48 
AnswerRe: How to call Fetch url using HTML ? Pin
Wishe199130-Sep-19 0:26
MemberWishe199130-Sep-19 0:26 
QuestionGrid Pin
RajaMohammed.A23-Sep-19 21:27
MemberRajaMohammed.A23-Sep-19 21:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.