问:
Why is variable empty for Set Range? [ISSUE HAS BECOME MOOT AND RESOLUTION NO LONGER NEEDED]
NOTE: I added some code below to provide a better idea of what I am attempting to do.  If there is a better way to do this, please share.

Although this is about the same project, it is a different topic, so I am starting a new thread.  The issue with the other thread still is unresolved.

This issue is a possible path towards the solution to the other problem, but the issue is totally different and will effect other parts of this project.

```<code>Dim rngcellsItemSKu As Excel.Range
Dim rngnameItemSKU
Dim rngnameItemSKUAsString As String
Dim ST as Recordset
Dim db as Database

Set rngcellsItemSKu = Excel.Range(Cell1:="V!A10:A15")

rngnameItemSKU = rngcellsItemSKu

rngcellsItemSKu.Name = "ItemSKU"
rngnameItemSKU = rngcellsItemSKu.Name

set db = DBEngine.OpenDatabase([DBFILENAME], False, False, "Excel 12.0;")

ST = "SELECT * FROM [V$] WHERE "" & rngnameItemSKU & "" IS NOT NULL"
Set rst = db.OpenRecordset(ST)
</code>```

The set rng**** line where the issue starts.  When I am in debug mode, it has no value.  When I place the mouse cursor over the rngcellsItemSKu variable it shows nothing.  Later on when I attempt to name the range so I can refer to it, the code crashes.  Why is this happening?

答:
Woah, what a strange method you're using :) First time see sth like that :)

Try this:

```<code>Dim rngcellsItemSKu As Range
Dim rngnameItemSKU
Dim rngnameItemSKUAsString As String

Set rngcellsItemSKu = Sheets("V").Range("A10:A15")
</code>```

Body:
NOTE: I added some code below to provide a better idea of what I am attempting to do.  If there is a better way to do this, please share.

Although this is about the same project, it is a different topic, so I am starting a new thread.  The issue with the other thread still is unresolved.

This issue is a possible path towards the solution to the other problem, but the issue is totally different and will effect other parts of this project.

Dim rngcellsItemSKu As Excel.Range
Dim rngnameItemSKU
Dim rngnameItemSKUAsString As String
Dim ST as Recordset
Dim db as Database

Set rngcellsItemSKu = Excel.Range(Cell1:="V!A10:A15")

rngnameItemSKU = rngcellsItemSKu

rngcellsItemSKu.Name = "ItemSKU"
rngnameItemSKU = rngcellsItemSKu.Name

set db = DBEngine.OpenDatabase([DBFILENAME], False, False, "Excel 12.0;")

ST = "SELECT * FROM [V$] WHERE "" & rngnameItemSKU & "" IS NOT NULL"
Set rst = db.OpenRecordset(ST)

The set rng**** line where the issue starts.  When I am in debug mode, it has no value.  When I place the mouse cursor over the rngcellsItemSKu variable it shows nothing.  Later on when I attempt to name the range so I can refer to it, the code crashes.  Why is this happening?

Body:
Woah, what a strange method you're using :) First time see sth like that :)

Try this:

Dim rngcellsItemSKu As Range
Dim rngnameItemSKU
Dim rngnameItemSKUAsString As String

Set rngcellsItemSKu = Sheets("V").Range("A10:A15")


来源: stackexchange

问:
Eclipse - List of default keyboard shortcuts
Is there a list of the default Eclipse keyboard shortcuts?  I'm generally looking for language agnostic things like starting the debugger or deleting an entire line in the source editor.</p>

答:
The full list of defaults in Eclipse 4.6 and earlier versions can be obtained from this GIT Hub page:
https://github.com/pellaton/eclipse-cheatsheet specifically https://github.com/pellaton/eclipse-cheatsheet/raw/master/eclipse4.6/eclipse-shortcuts-4.6.0.pdf

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
LinkedIn Share API stopped working for my domain about a week ago
I started to receive problems with sharing from LinkedIN last week. Prior to last week shares were working fine. When I try to share an article, their share program appears to go into a loop. The linkedIN share page comes up but it just spins and spins and spins.

This is the url – encoded url and encoded title.

https://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Fmydomain.com%2Fcs%2F24912%2F39%2Fnull%2F93538%2F&title=Is+There+Still+a+Place+for+Print+Marketing%3F

When I look in the developer tools on chrome it appears that the page is in some kind of loop.  As it keeps loading the following share page over and over…

https://www.linkedin.com/sharing/share?url=http%3A%2F%2Fmydomain%2Ecom%2Fcs%2F24912%2F39%2Fnull%2F93538%2F&title=Is+There+Still+a+Place+for+Print+Marketing%3F&trk=LI_BADGE_OLD

So I do the exact same call, just change the url to google

And it works.

I also have an app that is behaving the same way – when I post using the app – with rw permissions, I get an internal service error if I use my domain but I can post successfully using google.

Any help would be greatly appreciated.

答: This problem was resolved. The domain was listed in SPAMHAUS DBL (incorrectly, but that's a subject for another day). De-listed it and things are back to normal. LINKEDIN It would be great to return the real error versus an internal server error. For anyone that runs into this problem, check SMAPHAUS DBL listing.</p>


答:
Here is an example for M2.  It should be easy to see how to alter it for M5 and M15

```<code>declare @forexDate table
(
recDate datetime,
openVal float,
highVal float,
lowVal float,
closeVal float
)
INSERT INTO @forexDate VALUES('2016.01.03 17:00', 1.08701, 1.08713, 1.08701, 1.08713)
INSERT INTO @forexDate VALUES('2016.01.03 17:01', 1.08712, 1.08712, 1.08712, 1.08712)
INSERT INTO @forexDate VALUES('2016.01.03 17:02', 1.08708, 1.08722, 1.08708, 1.08722)
INSERT INTO @forexDate VALUES('2016.01.03 17:03', 1.08717, 1.08723, 1.08717, 1.08723)
INSERT INTO @forexDate VALUES('2016.01.03 17:04', 1.08718, 1.08718, 1.08711, 1.08711)
INSERT INTO @forexDate VALUES('2016.01.03 17:05', 1.08703, 1.08716, 1.08701, 1.08712)
INSERT INTO @forexDate VALUES('2016.01.03 17:06', 1.08721, 1.08721, 1.0871,  1.0871)
INSERT INTO @forexDate VALUES('2016.01.03 17:07', 1.08712, 1.08715, 1.08712, 1.08712)
INSERT INTO @forexDate VALUES('2016.01.03 17:08', 1.08711, 1.0872, 1.08711, 1.08713)
INSERT INTO @forexDate VALUES('2016.01.03 17:09', 1.08716, 1.08723, 1.08708, 1.08708)

SELECT o.recDate, o.openVal, c.closeVal, mx.highVal, mn.lowVal FROM
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) o
inner join
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) c
on o.Batch = c.Batch
inner join
(SELECT Batch, MAX(highVal) as highVal FROM
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) mxpre GROUP BY Batch) mx
on mx.Batch = o.Batch
inner join
(SELECT Batch, MIN(lowVal) as lowVal FROM
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) mnpre GROUP BY Batch) mn
on mn.Batch = o.Batch
WHERE o.BatchPos = 0 AND c.BatchPos = 1
</code>```

The results should look like this:

```<code>recDate openVal closeVal    highVal lowVal
2016-01-03 17:00:00.000 1.08701 1.08712 1.08713 1.08701
2016-01-03 17:02:00.000 1.08708 1.08723 1.08723 1.08708
2016-01-03 17:04:00.000 1.08718 1.08712 1.08718 1.08701
2016-01-03 17:06:00.000 1.08721 1.08712 1.08721 1.0871
2016-01-03 17:08:00.000 1.08711 1.08708 1.08723 1.08708
</code>```

I hope this is what you were after!

In practice you would want to insert the Batch and BatchPos pre-results into a temporary table and then do a series of self-joins, rather than everything on the fly as above!

Title: How to convert FOREX Historical data from M1 to M2, M5 and M15 timeframes?

Body:
I have several years of FOREX historical data, but it's listed minute by minute. I would like to know how do I do to convert it to M2, M5 and M15. I tried lots of things and methods, but none worked.

Excel functions or SQL scripts are welcome.

Below is listed a little sample of data format.

Date        Time    Open    High    Low     Close
2016.01.03  17:00   1.08701 1.08713 1.08701 1.08713
2016.01.03  17:01   1.08712 1.08712 1.08712 1.08712
2016.01.03  17:02   1.08708 1.08722 1.08708 1.08722
2016.01.03  17:03   1.08717 1.08723 1.08717 1.08723
2016.01.03  17:04   1.08718 1.08718 1.08711 1.08711
2016.01.03  17:05   1.08703 1.08716 1.08701 1.08712
2016.01.03  17:06   1.08721 1.08721 1.0871  1.0871
2016.01.03  17:07   1.08712 1.08715 1.08712 1.08712
2016.01.03  17:08   1.08711 1.0872  1.08711 1.08713
2016.01.03  17:09   1.08716 1.08723 1.08708 1.08708

Body:
Here is an example for M2.  It should be easy to see how to alter it for M5 and M15

declare @forexDate table
(
recDate datetime,
openVal float,
highVal float,
lowVal float,
closeVal float
)
INSERT INTO @forexDate VALUES('2016.01.03 17:00', 1.08701, 1.08713, 1.08701, 1.08713)
INSERT INTO @forexDate VALUES('2016.01.03 17:01', 1.08712, 1.08712, 1.08712, 1.08712)
INSERT INTO @forexDate VALUES('2016.01.03 17:02', 1.08708, 1.08722, 1.08708, 1.08722)
INSERT INTO @forexDate VALUES('2016.01.03 17:03', 1.08717, 1.08723, 1.08717, 1.08723)
INSERT INTO @forexDate VALUES('2016.01.03 17:04', 1.08718, 1.08718, 1.08711, 1.08711)
INSERT INTO @forexDate VALUES('2016.01.03 17:05', 1.08703, 1.08716, 1.08701, 1.08712)
INSERT INTO @forexDate VALUES('2016.01.03 17:06', 1.08721, 1.08721, 1.0871,  1.0871)
INSERT INTO @forexDate VALUES('2016.01.03 17:07', 1.08712, 1.08715, 1.08712, 1.08712)
INSERT INTO @forexDate VALUES('2016.01.03 17:08', 1.08711, 1.0872, 1.08711, 1.08713)
INSERT INTO @forexDate VALUES('2016.01.03 17:09', 1.08716, 1.08723, 1.08708, 1.08708)

SELECT o.recDate, o.openVal, c.closeVal, mx.highVal, mn.lowVal FROM
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) o
inner join
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) c
on o.Batch = c.Batch
inner join
(SELECT Batch, MAX(highVal) as highVal FROM
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) mxpre GROUP BY Batch) mx
on mx.Batch = o.Batch
inner join
(SELECT Batch, MIN(lowVal) as lowVal FROM
(SELECT recDate, openVal, highVal, lowVal, closeVal,
CAST((RowNum + 1) / 2 as int) AS Batch, (RowNum + 1) % 2 AS BatchPos FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY recDate) AS RowNum FROM @forexDate) x) mnpre GROUP BY Batch) mn
on mn.Batch = o.Batch
WHERE o.BatchPos = 0 AND c.BatchPos = 1

The results should look like this:

recDate openVal closeVal    highVal lowVal
2016-01-03 17:00:00.000 1.08701 1.08712 1.08713 1.08701
2016-01-03 17:02:00.000 1.08708 1.08723 1.08723 1.08708
2016-01-03 17:04:00.000 1.08718 1.08712 1.08718 1.08701
2016-01-03 17:06:00.000 1.08721 1.08712 1.08721 1.0871
2016-01-03 17:08:00.000 1.08711 1.08708 1.08723 1.08708

I hope this is what you were after!

In practice you would want to insert the Batch and BatchPos pre-results into a temporary table and then do a series of self-joins, rather than everything on the fly as above!


问:
Passing data through Angular2 router
I have a component where I select a set of image objects. I want to pass these selected images to my new route, CreateAlbum. The data it nested and wouldn't be suitable to pass as URL parameters.

Is there any easy way to achieve this?

Here's my code to navigate to the route

```<code>  public gotoCreateAlbum(): void {
    this.router.navigate([('/create-album')])
  }
</code>```

My selected data sits in this variable

```<code>@Input() selectedPhotos: IPhoto[];
</code>```

and this is my routing module

```<code>const routes: Routes = [
  { path: 'photos',  component: PhotosComponent},
  { path: 'photos/:filter', component: PhotosComponent},
  { path: 'create-album', component: CreateAlbumComponent}
];
</code>```

Basically I want to perform the same operations as if the CreateAlbum component was a child to my current component in which case I would have used @Input()

答:
Unless you want users to manipulate the query string in the addressbar, do a "atob" and "btoa" before sending and after receiving the data. Just a little
security

Also, if you don't want to have a subscription, you can use the Route snapshot param as follows (just that it doesn't keep on updating like an observable, so unless the component gets re-init, it won't be getting updated value if any. Hence a good place to get the value is in the ngOnInit event handler

```<code>// before
this._router.navigate(["/welcome/" + atob(userName)]);

// after
ngOnInit() {
    this.userName = btoa(this.route.snapshot.params['userName']);
}
</code>```

Title: Passing data through Angular2 router

Body:
I have a component where I select a set of image objects. I want to pass these selected images to my new route, CreateAlbum. The data it nested and wouldn't be suitable to pass as URL parameters.

Is there any easy way to achieve this?

Here's my code to navigate to the route

  public gotoCreateAlbum(): void {
    this.router.navigate([('/create-album')])
  }

My selected data sits in this variable

@Input() selectedPhotos: IPhoto[];

and this is my routing module

const routes: Routes = [
  { path: 'photos',  component: PhotosComponent},
  { path: 'photos/:filter', component: PhotosComponent},
  { path: 'create-album', component: CreateAlbumComponent}
];

Basically I want to perform the same operations as if the CreateAlbum component was a child to my current component in which case I would have used @Input()

Body:
Unless you want users to manipulate the query string in the addressbar, do a "atob" and "btoa" before sending and after receiving the data. Just a little
security

Also, if you don't want to have a subscription, you can use the Route snapshot param as follows (just that it doesn't keep on updating like an observable, so unless the component gets re-init, it won't be getting updated value if any. Hence a good place to get the value is in the ngOnInit event handler

// before
this._router.navigate(["/welcome/" + atob(userName)]);

// after
ngOnInit() {
    this.userName = btoa(this.route.snapshot.params['userName']);
}


问:
Contacts not shown in contacts app - when using sample contact manager application
When using the sample app - contact manager, and adding a contact where you have not set up an account. The contacts get written to the database, but do not show up in the contacts application. The contacts application also does not seem to require an account be setup, but does show contacts which are added through the menu -> add method.

Is there an updated ContactManager app for 2.2+ which addresses this issue? Is there a missing parameter that needs to be set to allow visibility on the android contacts application?

The only difference seems to be that the contact_in_visible_group is set to zero when it is added via the ContactManager, it is set to one when set via the contacts application. Looking through the android source code for Contacts did not seem to yield any way to modify this value, and no way to change it via the API.

Thanks

答: You need to make sure you pass a NULL account name in w/ the new contact not a blank string..</p>


问:
NG2-Charts Template parse errors: Can't bind to 'datasets' since it isn't a known property of 'canvas'
I am trying to use the examples for the ng2-charts found in https://valor-software.com/ng2-charts/

It s not working and I am getting this errors
zone.js:642

```<code>Unhandled Promise rejection: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("
<div style="display: block">
    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
</code>```

I installed

```<code>npm install ng2-charts --save
npm install chart.js --save
</code>```

My component.html

```<code><div style="display: block">
    <canvas baseChart
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartClicked($event)"></canvas>
  </div>
</code>```

My component.ts

```<code>import Chart from 'chart.js';

@Component({
  templateUrl: './filename.component.html',
  styleUrls: ['./filename.component.css', '../file.css']

})
  // Doughnut
  public doughnutChartLabels:string[] = ['Download Sales', 'In-Store Sales', 'Mail-Order Sales'];
  public doughnutChartData:number[] = [350, 450, 100];
  public doughnutChartType:string = 'doughnut';

  // events
  public chartClicked(e:any):void {
    console.log(e);
  }

  public chartHovered(e:any):void {
    console.log(e);
  }
</code>```

my app.module.ts

```<code>import { ChartsModule } from 'ng2-charts/ng2-charts';
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
      ChartsModule,
</code>```

.......

My index.html

```<code> <script src="node_modules/chart.js/src/chart.js"></script>
</code>```

Full ERROR

```<code>Unhandled Promise rejection: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("
<div style="display: block">
    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("
<div style="display: block">
    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57 Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("
<div style="display: block">
    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57
api.onUnhandledError @ zone.js:642
handleUnhandledRejection @ zone.js:666
_loop_1 @ zone.js:657
api.microtaskDrainDone @ zone.js:661
drainMicroTaskQueue @ zone.js:592
zone.js:644 Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("
<div style="display: block">
    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("
<div style="display: block">
    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57
    at resolvePromise (http://localhost:4200/polyfills.bundle.js:2779:31)
    at resolvePromise (http://localhost:4200/polyfills.bundle.js:2750:17)
    at http://localhost:4200/polyfills.bundle.js:2827:17
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:2434:31)
    at Zone.webpackJsonp.626.Zone.runTask (http://localhost:4200/polyfills.bundle.js:2201:47)
    at drainMicroTaskQueue (http://localhost:4200/polyfills.bundle.js:2594:35)
    at <anonymous>
</code>```

答:
Please ensure that your barChartData contains data when you loaded your canvas.
Also you can get it in ngOnInit():void{ //there }

Body:
I am trying to use the examples for the ng2-charts found in https://valor-software.com/ng2-charts/

It s not working and I am getting this errors
zone.js:642

Unhandled Promise rejection: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("

    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8

I installed

npm install ng2-charts --save
npm install chart.js --save

My component.html

    <canvas baseChart
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartClicked($event)"></canvas>

My component.ts

import Chart from 'chart.js';

@Component({
  templateUrl: './filename.component.html',
  styleUrls: ['./filename.component.css', '../file.css']

})
  // Doughnut
  public doughnutChartLabels:string[] = ['Download Sales', 'In-Store Sales', 'Mail-Order Sales'];
  public doughnutChartData:number[] = [350, 450, 100];
  public doughnutChartType:string = 'doughnut';

  // events
  public chartClicked(e:any):void {
    console.log(e);
  }

  public chartHovered(e:any):void {
    console.log(e);
  }

my app.module.ts

import { ChartsModule } from 'ng2-charts/ng2-charts';
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
      ChartsModule,

.......

My index.html

Full ERROR

Unhandled Promise rejection: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("

    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("

    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57 Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("

    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57
api.onUnhandledError @ zone.js:642
handleUnhandledRejection @ zone.js:666
_loop_1 @ zone.js:657
api.microtaskDrainDone @ zone.js:661
drainMicroTaskQueue @ zone.js:592
zone.js:644 Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("

    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
Error: Template parse errors:
Can't bind to 'datasets' since it isn't a known property of 'canvas'. ("

    <canvas baseChart
        [ERROR ->][datasets]="barChartData"
        [labels]="barChartLabels"
        [options]="barChartOptions"
"): ng:///FAModule/Step0Component.html@255:8
Can't bind to 'labels' since it isn't a known property of 'canvas'. ("
    <canvas baseChart
        [datasets]="barChartData"
        [ERROR ->][labels]="barChartLabels"
        [options]="barChartOptions"
        [legend]="barChartLegend"
"): ng:///FAModule/Step0Component.html@256:8
Can't bind to 'options' since it isn't a known property of 'canvas'. ("
        [datasets]="barChartData"
        [labels]="barChartLabels"
        [ERROR ->][options]="barChartOptions"
        [legend]="barChartLegend"
        [chartType]="barChartType"
"): ng:///FAModule/Step0Component.html@257:8
Can't bind to 'legend' since it isn't a known property of 'canvas'. ("
        [labels]="barChartLabels"
        [options]="barChartOptions"
        [ERROR ->][legend]="barChartLegend"
        [chartType]="barChartType"
        (chartHover)="chartHovered($ev"): ng:///FAModule/Step0Component.html@258:8
Can't bind to 'chartType' since it isn't a known property of 'canvas'. ("
        [options]="barChartOptions"
        [legend]="barChartLegend"
        [ERROR ->][chartType]="barChartType"
        (chartHover)="chartHovered($event)"
        (chartClick)="chartC"): ng:///FAModule/Step0Component.html@259:8
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57
    at syntaxError (http://localhost:4200/vendor.bundle.js:91797:34)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:102288:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:116039:39)
    at http://localhost:4200/vendor.bundle.js:115963:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:115963:19)
    at createResult (http://localhost:4200/vendor.bundle.js:115848:19)
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:2401:26)
    at Zone.webpackJsonp.626.Zone.run (http://localhost:4200/polyfills.bundle.js:2151:43)
    at http://localhost:4200/polyfills.bundle.js:2827:57
    at resolvePromise (http://localhost:4200/polyfills.bundle.js:2779:31)
    at resolvePromise (http://localhost:4200/polyfills.bundle.js:2750:17)
    at http://localhost:4200/polyfills.bundle.js:2827:17
    at ZoneDelegate.webpackJsonp.626.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:2434:31)
    at Zone.webpackJsonp.626.Zone.runTask (http://localhost:4200/polyfills.bundle.js:2201:47)
    at drainMicroTaskQueue (http://localhost:4200/polyfills.bundle.js:2594:35)
    at <anonymous>


问:
jQuery - Stop form submit depending on ajax response, otherwise let it submit
I setup some jQuery code so that when a user tries to submit this form, it checks to see what the ajax response is from our 'check_bid_locked' function in php. If it's 'assigned', 'expired', or 'yes', then it uses e.prevent_default() to stop the submit and show a modal popup message (which is working).

What I can't seem to figure out is how to let the form be SUBMITTED if the response doesn't match any of these. Basically, if the response is 'no' then we want the form to be submitted. Any ideas?

HTML

```<code>    <form onsubmit="return true check_submits();" method="post" action="<?php echo get_permalink($pid); ?>">
   <input type="hidden" name="control_id" value="<?php echo base64_encode($pid); ?>" />
   <input class="submit_bottom" id="submits_crt" type="submit" name="bid_now_reverse" value="<?php _e("Place Bid",'BidTheme'); ?>" />
  </form>
</code>```

Jquery

```<code>$(document).ready("#bid_now_reverse").submit(function(e) {

var allowSubmit = false;
if (allowSubmit == false) {
e.preventDefault();
}

    var data = {
        'action': 'check_bid_locked',
        'pid': <?php echo $pid; ?>,
        'uid': <?php echo $uid; ?>
    };

    jQuery.post('<?php echo admin_url( 'admin-ajax.php' ); ?>', data,
function(response) {
            //If bid NOT locked
            if(response == 'no') {
            allowSubmit == true;
            }
            //If Assigned
            if(response == 'assigned') {
            confirm('<div class="bid_panel_box_title">Task Has Been
Assigned</div><div class="padd10_center">Your offer can\'t be deleted.
</div>', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title:
"Close", value: "Cancel" }

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
            //Reload page END
        );
        //If Expired
    }else if(response == 'expired'){
        confirm('<div class="bid_panel_box_title">Task Has Expired</div><div class="padd10_center">Your offer can\'t be deleted.</div>', {
                /*
                Define your buttons here, can handle multiple buttons
                with custom title and values
                */
                buttons: [
                    { class: "delete_button15", type: "button", title: "Close", value: "Cancel" }

                ],
                modal: true
            },
            //Reload page START
            function(resp) {
               console.log(resp);
        if(resp == 'Cancel'){
            window.location.reload(true);
        } }
            //Reload page END
        );
        //If Change Offer Locked
    }else if(response == 'yes'){
    allowSubmit = false;
        confirm('<div class="bid_panel_box_title">Offer Change Locked</div><div class="padd10_center">The Poster is reviewing your offer.<br/><br/>Check back shortly to see if it was accepted or to change it.</div>', {
                /*
                Define your buttons here, can handle multiple buttons
                with custom title and values
                */
                buttons: [
                    { class: "delete_button15", type: "button", title: "Close", value: "Cancel"}

                ],
                modal: true
            },
            //Reload page START
            function(resp) {
               console.log(resp);
        if(resp == 'Cancel'){
            window.location.reload(true);
        } }
            //Reload page END
        );
        }
});
</code>```

});

答:
As per the suggestions so far, this is what I've changed my code to but it still will not submit if the ajax response is 'no'.

HTML

```<code><form id="submit_offer"  method="post" action="<?php echo get_permalink($pid); ?>">
<input class="submit_bottom" id="submits_crt" type="submit" name="bid_now_reverse" value="<?php _e("Place Bid",'ProjectTheme'); ?>" />
</form>
</code>```

JQUERY

```<code>$(document).ready("#bid_now_reverse").submit(function(e) {

    var data = {
        'action': 'check_bid_locked',
        'pid': <?php echo $pid; ?>,
        'uid': <?php echo $uid; ?>
    };

    e.preventDefault();

        jQuery.post('<?php echo admin_url( 'admin-ajax.php' ); ?>', data, function(response) {
            //If offer NOT locked then allow form to submit
            if(response == 'no'){
            $('form').submit();
            //If Assigned
            }else if(response == 'assigned') {
            confirm('<div class="bid_panel_box_title">Task Has Been Assigned</div><div class="padd10_center">Your offer can\'t be deleted.</div>', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title: "Close", value: "Cancel" }

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
                //Reload page END
            );
            //If Expired
        }else if(response == 'expired'){
            confirm('<div class="bid_panel_box_title">Task Has Expired</div><div class="padd10_center">Your offer can\'t be deleted.</div>', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title: "Close", value: "Cancel" }

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
                //Reload page END
            );
            //If Change Offer Locked
        }else if(response == 'yes'){
            confirm('<div class="bid_panel_box_title">Offer Change Locked</div><div class="padd10_center">The Poster is reviewing your offer.<br/><br/>Check back shortly to see if it was accepted or to change it.</div>', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title: "Close", value: "Cancel"}

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
                //Reload page END
            );
            }
    });
});
</code>```

Body:
I setup some jQuery code so that when a user tries to submit this form, it checks to see what the ajax response is from our 'check_bid_locked' function in php. If it's 'assigned', 'expired', or 'yes', then it uses e.prevent_default() to stop the submit and show a modal popup message (which is working).

What I can't seem to figure out is how to let the form be SUBMITTED if the response doesn't match any of these. Basically, if the response is 'no' then we want the form to be submitted. Any ideas?

HTML

    <form onsubmit="return true check_submits();" method="post" action="<?php echo get_permalink($pid); ?>">
   <input type="hidden" name="control_id" value="<?php echo base64_encode($pid); ?>" />
   <input class="submit_bottom" id="submits_crt" type="submit" name="bid_now_reverse" value="<?php _e("Place Bid",'BidTheme'); ?>" />
  </form>

Jquery

$(document).ready("#bid_now_reverse").submit(function(e) {

var allowSubmit = false;
if (allowSubmit == false) {
e.preventDefault();
}

    var data = {
        'action': 'check_bid_locked',
        'pid': <?php echo $pid; ?>,
        'uid': <?php echo $uid; ?>
    };

    jQuery.post('<?php echo admin_url( 'admin-ajax.php' ); ?>', data,
function(response) {
            //If bid NOT locked
            if(response == 'no') {
            allowSubmit == true;
            }
            //If Assigned
            if(response == 'assigned') {
            confirm('
Task Has Been
Assigned

Your offer can\'t be deleted.

', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title:
"Close", value: "Cancel" }

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
            //Reload page END
        );
        //If Expired
    }else if(response == 'expired'){
        confirm('
Task Has Expired

Your offer can\'t be deleted.
', {
                /*
                Define your buttons here, can handle multiple buttons
                with custom title and values
                */
                buttons: [
                    { class: "delete_button15", type: "button", title: "Close", value: "Cancel" }

                ],
                modal: true
            },
            //Reload page START
            function(resp) {
               console.log(resp);
        if(resp == 'Cancel'){
            window.location.reload(true);
        } }
            //Reload page END
        );
        //If Change Offer Locked
    }else if(response == 'yes'){
    allowSubmit = false;
        confirm('
Offer Change Locked

The Poster is reviewing your offer.

Check back shortly to see if it was accepted or to change it.
', {
                /*
                Define your buttons here, can handle multiple buttons
                with custom title and values
                */
                buttons: [
                    { class: "delete_button15", type: "button", title: "Close", value: "Cancel"}

                ],
                modal: true
            },
            //Reload page START
            function(resp) {
               console.log(resp);
        if(resp == 'Cancel'){
            window.location.reload(true);
        } }
            //Reload page END
        );
        }
});

});

Body:
As per the suggestions so far, this is what I've changed my code to but it still will not submit if the ajax response is 'no'.

HTML

<form id="submit_offer"  method="post" action="<?php echo get_permalink($pid); ?>">
<input class="submit_bottom" id="submits_crt" type="submit" name="bid_now_reverse" value="<?php _e("Place Bid",'ProjectTheme'); ?>" />
</form>

JQUERY

$(document).ready("#bid_now_reverse").submit(function(e) {

    var data = {
        'action': 'check_bid_locked',
        'pid': <?php echo $pid; ?>,
        'uid': <?php echo $uid; ?>
    };

    e.preventDefault();

        jQuery.post('<?php echo admin_url( 'admin-ajax.php' ); ?>', data, function(response) {
            //If offer NOT locked then allow form to submit
            if(response == 'no'){
            $('form').submit();
            //If Assigned
            }else if(response == 'assigned') {
            confirm('<div class="bid_panel_box_title">Task Has Been Assigned</div><div class="padd10_center">Your offer can\'t be deleted.</div>', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title: "Close", value: "Cancel" }

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
                //Reload page END
            );
            //If Expired
        }else if(response == 'expired'){
            confirm('<div class="bid_panel_box_title">Task Has Expired</div><div class="padd10_center">Your offer can\'t be deleted.</div>', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title: "Close", value: "Cancel" }

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
                //Reload page END
            );
            //If Change Offer Locked
        }else if(response == 'yes'){
            confirm('<div class="bid_panel_box_title">Offer Change Locked</div><div class="padd10_center">The Poster is reviewing your offer.<br/><br/>Check back shortly to see if it was accepted or to change it.</div>', {
                    /*
                    Define your buttons here, can handle multiple buttons
                    with custom title and values
                    */
                    buttons: [
                        { class: "delete_button15", type: "button", title: "Close", value: "Cancel"}

                    ],
                    modal: true
                },
                //Reload page START
                function(resp) {
                   console.log(resp);
            if(resp == 'Cancel'){
                window.location.reload(true);
            } }
                //Reload page END
            );
            }
    });
});


问:
AS3 Access a method inside the Main class from another class . Gives error?
I have trouble with actionScript , im trying to use a simple one line code to access a method inside the Document Class (Main) , but every time i got error . i tried the same code with a movieClip on stage, it work nicely .

Main Class linked to the fla :

```<code>package {

import flash.display.*;
import flash.events.*;

public class Main extends MovieClip {

    public function Main() {

        if (stage) {
            init();

        }
        else addEventListener(Event.ADDED_TO_STAGE, init);

    }
    private function init(e:Event = null):void {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        button.addEventListener(MouseEvent.CLICK,_click);

    }
    private function _click(e:MouseEvent):void {
        var l:Leecher = new Leecher();
        l.leech();
    }

    public function callMe():void {
        trace("hey nice work");
    }

}

}
</code>```

Leecher Class :

```<code>package {

    import flash.display.*;

    public class Leecher extends MovieClip {

        public function leech():void
        {
            trace(" leech function ");

            Main(parent).callMe();       // output null object
            Main(root).callMe();        // output null object
            Main(Main).callMe();       // output null object

        }

    }

}
</code>```

The Same code , but the class linked to a button on stage

```<code>package
{

    import flash.display.*;
    import flash.events.*;

    public class Button extends MovieClip {

        public function Button() {
            this.addEventListener(MouseEvent.CLICK,r_click);
        }
        private function r_click(e:MouseEvent):void {
            var l:Leecher = new Leecher();
            l.leech();
            Main(parent).callMe();  // hey nice work
            Main(root).callMe();    // hey nice work
            Main(Main).callMe();    // output null object

        }
    }

}
</code>```

答:
The errors are because when that code runs, the Leecher instance has not yet been added to the display list,  and as such does not have a parent or root or stage (so parent is null).

Here is a breakdown of what's happening (explained with code comments):

```<code>private function _click(e:MouseEvent):void {
    //you instantiate a new Leecher object
    var l:Leecher = new Leecher();

    //you call leech, but this new object does not have a parent because you haven't added it to the display list (via `addChild(l)`)
    l.leech();
}

//your saying parent should be of type Main, then call the callMe method.  However, parent is null because this object is not on the display list
Main(parent).callMe();

//same as above, except using root
Main(root).callMe();

//Here you are saying the Main class is of type Main (which since Main is a class and not an instance of Main will error or be null)
Main(Main).callMe();
</code>```

The root, parent & stage vars of a display object are only populated when said display object is added to to the display list.  In the case of root & stage the parent (and any grand parents) must also be added so that the top most parent/grandparent is the stage.

As a result, you need to wait until it's safe to access parent by listening for the Event.ADDED_TO_STAGE event.

```<code>private function _click(e:MouseEvent):void {
    var l:Leecher = new Leecher();

    //call the leech method once the child has been added to the stage and has a parent value
    l.addEventListener(Event.ADDED_TO_STAGE, l.leech, false, 0, true);
    addChild(l);
}
</code>```

If you do the above, you'll need to add an optional event parameter to the leech method or you'll get an error:

```<code>public function leech(e:Event = null):void
{
</code>```

To make your Main class easily accessible, you could use a static reference.
Static vars are not tied to an instance of an object, but to the class itself.

```<code>public class Main extends MovieClip {
    //create a static var that holds a reference to the root/main instance
    public static var main:Main;

    public function Main() {
        //assign the static var to this (the instance of Main)
        main = this;

        //...rest of code
</code>```

If you do that, you can asses your root anywhere in your code by doing Main.main so in your example you could then do:

```<code>Main.main.callMe();
</code>```

I'd recommend reading about static vars more before going crazy using them. Doing what I've just shown for an easy reference to your document class / root is safe, but in other contexts there are some memory & performance nuances it's best to be aware of.

Body:
I have trouble with actionScript , im trying to use a simple one line code to access a method inside the Document Class (Main) , but every time i got error . i tried the same code with a movieClip on stage, it work nicely .

Main Class linked to the fla :

package {

import flash.display.*;
import flash.events.*;

public class Main extends MovieClip {

    public function Main() {

        if (stage) {
            init();

        }
        else addEventListener(Event.ADDED_TO_STAGE, init);

    }
    private function init(e:Event = null):void {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        button.addEventListener(MouseEvent.CLICK,_click);

    }
    private function _click(e:MouseEvent):void {
        var l:Leecher = new Leecher();
        l.leech();
    }

    public function callMe():void {
        trace("hey nice work");
    }

}

}

Leecher Class :

package {

    import flash.display.*;

    public class Leecher extends MovieClip {

        public function leech():void
        {
            trace(" leech function ");

            Main(parent).callMe();       // output null object
            Main(root).callMe();        // output null object
            Main(Main).callMe();       // output null object

        }

    }

}

The Same code , but the class linked to a button on stage

package
{

    import flash.display.*;
    import flash.events.*;

    public class Button extends MovieClip {

        public function Button() {
            this.addEventListener(MouseEvent.CLICK,r_click);
        }
        private function r_click(e:MouseEvent):void {
            var l:Leecher = new Leecher();
            l.leech();
            Main(parent).callMe();  // hey nice work
            Main(root).callMe();    // hey nice work
            Main(Main).callMe();    // output null object

        }
    }

}

Body:
The errors are because when that code runs, the Leecher instance has not yet been added to the display list,  and as such does not have a parent or root or stage (so parent is null).

Here is a breakdown of what's happening (explained with code comments):

private function _click(e:MouseEvent):void {
    //you instantiate a new Leecher object
    var l:Leecher = new Leecher();

    //you call leech, but this new object does not have a parent because you haven't added it to the display list (via `addChild(l)`)
    l.leech();
}

//your saying parent should be of type Main, then call the callMe method.  However, parent is null because this object is not on the display list
Main(parent).callMe();

//same as above, except using root
Main(root).callMe();

//Here you are saying the Main class is of type Main (which since Main is a class and not an instance of Main will error or be null)
Main(Main).callMe();

The root, parent & stage vars of a display object are only populated when said display object is added to to the display list.  In the case of root & stage the parent (and any grand parents) must also be added so that the top most parent/grandparent is the stage.

As a result, you need to wait until it's safe to access parent by listening for the Event.ADDED_TO_STAGE event.

private function _click(e:MouseEvent):void {
    var l:Leecher = new Leecher();

    //call the leech method once the child has been added to the stage and has a parent value
    l.addEventListener(Event.ADDED_TO_STAGE, l.leech, false, 0, true);
    addChild(l);
}

If you do the above, you'll need to add an optional event parameter to the leech method or you'll get an error:

public function leech(e:Event = null):void
{

To make your Main class easily accessible, you could use a static reference.
Static vars are not tied to an instance of an object, but to the class itself.

public class Main extends MovieClip {
    //create a static var that holds a reference to the root/main instance
    public static var main:Main;

    public function Main() {
        //assign the static var to this (the instance of Main)
        main = this;

        //...rest of code

If you do that, you can asses your root anywhere in your code by doing Main.main so in your example you could then do:

Main.main.callMe();

I'd recommend reading about static vars more before going crazy using them. Doing what I've just shown for an easy reference to your document class / root is safe, but in other contexts there are some memory & performance nuances it's best to be aware of.


问:
The scroll bar disappears when a jquery confirm dialogue is shown
The scroll bar on the page disappears when a jquery confirm dialogue is shown, this causes the page to jump to the right.  The JavaScript code for the dialogue is as follows:

```<code><script src="vendor/jquery-confirm.min.js"></script>
<link href="vendor/jquery-confirm.min.css" rel="stylesheet" type="text/css">
<script>
    function confirmDialog(content, func, parameter) {
        $.confirm({
            title: "",
            content: content,
            confirmButton: "Yes",
            cancelButton: "No",
            theme: "black",
            confirm: function() { func(parameter); },
            cancel: function() { }
        });
    }
</script>
</code>```

I am using the CSS:

```<code>body {
    overflow-y: scroll;
}
</code>```

How can I prevent this from happening?

Update

I tried adding "important", but inspecting the page in Firefox I see there is this CSS:

```<code>body.jconfirm-noscroll {
    overflow: hidden !important;
}
</code>```

And there is a line through:

```<code>overflow-y: scroll !important;
</code>```

答:
CSS is mathematics. Each selector boils down to a specificity number. If numbers are equal, the last one applies. If they are not equal, the highest applies, regardless of order.

You could try to use tools like specificity calculator to link selectors to particular numbers but, really, you don't need to.

The general point is:

!important > style="inline rules" > #id > .class > attribute = element
```

<p>The selector you're trying to override is:</p>

<pre class="lang-css prettyprint-override"><code>body.jconfirm-noscroll {
   some rule !important;
}
</code>```

This means !important + 1 x class + 1 x element. You could override it with the same exact selector as long as yours is placed lower in page (parsed later by browser).

Or, to make sure, you could override it with

html body.jconfirm-noscroll {
  some rule !important;
}
```

Or, of course, if you know any other class you have on body, add it to the selector. Or put an #id on  and use it. It will beat the .class. But you can't beat body.class !important with body !important. That is a certainty.

Important note: There will be cases when you are absolutely certain your selector is stronger, but it still refuses to apply. Don't dispair. It happens to us all. From experience, it falls down in any of these cases:

you have a syntax error in a previous rule which disables the one you're currently looking at (check for unclosed braces)

an even stronger selector applies. please be aware that inline styles (placed in style attribute of the element) are actually stronger than #ids. That's why styles applied via javascript usually apply. They don't override !importants, though

your markup is utterly broken. In rare cases, when your markup is not valid, css doesn't apply because the elements you are looking at are not the elements you think they are for the browser. I'm talking cases of nested  tags and similar

if none of the above help, check your selector closely. Check it against the markup, step by step. Make sure it has spaces where it should have and doesn't have where it shouldn't have. I'm considered (by some) a CSS expert but you'd be surprised at how many times I write faulty selectors and it takes me a good minute or two to spot the typo. It has something to do with being human, I guess.

Body:
The scroll bar on the page disappears when a jquery confirm dialogue is shown, this causes the page to jump to the right.  The JavaScript code for the dialogue is as follows:

<link href="vendor/jquery-confirm.min.css" rel="stylesheet" type="text/css">

I am using the CSS:

body {
    overflow-y: scroll;
}

How can I prevent this from happening?

Update

I tried adding "important", but inspecting the page in Firefox I see there is this CSS:

body.jconfirm-noscroll {
    overflow: hidden !important;
}

And there is a line through:

overflow-y: scroll !important;

Body:
CSS is mathematics. Each selector boils down to a specificity number. If numbers are equal, the last one applies. If they are not equal, the highest applies, regardless of order.

You could try to use tools like specificity calculator to link selectors to particular numbers but, really, you don't need to.

The general point is:

!important > style="inline rules" > #id > .class > attribute = element

The selector you're trying to override is:

body.jconfirm-noscroll {
   some rule !important;
}

This means !important + 1 x class + 1 x element. You could override it with the same exact selector as long as yours is placed lower in page (parsed later by browser).

Or, to make sure, you could override it with

html body.jconfirm-noscroll {
  some rule !important;
}

Or, of course, if you know any other class you have on body, add it to the selector. Or put an #id on <body> and use it. It will beat the .class. But you can't beat body.class !important with body !important. That is a certainty.

Important note: There will be cases when you are absolutely certain your selector is stronger, but it still refuses to apply. Don't dispair. It happens to us all. From experience, it falls down in any of these cases:

you have a syntax error in a previous rule which disables the one you're currently looking at (check for unclosed braces)

an even stronger selector applies. please be aware that inline styles (placed in style attribute of the element) are actually stronger than #ids. That's why styles applied via javascript usually apply. They don't override !importants, though

your markup is utterly broken. In rare cases, when your markup is not valid, css doesn't apply because the elements you are looking at are not the elements you think they are for the browser. I'm talking cases of nested <a> tags and similar

if none of the above help, check your selector closely. Check it against the markup, step by step. Make sure it has spaces where it should have and doesn't have where it shouldn't have. I'm considered (by some) a CSS expert but you'd be surprised at how many times I write faulty selectors and it takes me a good minute or two to spot the typo. It has something to do with being human, I guess.


问:
Memory usage in MiB/KiB by PID
I need command to get process memory usage in MiB or KiB by PID. I prefer the number I see in gnome-system-monitor in "Memory" column. I tried a lot of different commands but all of them give me some other numbers.

For example, I've tried ps with different keys. The most interesting was
ps aux. The RSS column is something close but number here greater than in gnome-system-monitor. A lot of answers on question similar to mine contain top command but it gives memory usage in percents.

答:
```<code>cat /proc/YourPid/status

ps aux YourPid

top -p YourPid

pmap -x YourPid
</code>```

All of them give process memory usage; top gives both percents and absolute value (RES - Resident size)

Look at Understanding Process memory and How to measure actual memory usage of an application or process? for more details about memory usage and monitor.

Title: Memory usage in MiB/KiB by PID

Body:
cat /proc/YourPid/status

ps aux YourPid

top -p YourPid

pmap -x YourPid

All of them give process memory usage; top gives both percents and absolute value (RES - Resident size)

Look at Understanding Process memory and How to measure actual memory usage of an application or process? for more details about memory usage and monitor.


问:
Deserialize appsettings.json with ASP.NET Core
I am doing encryption/decryption of my appsettings.json file within my ASP.NET application.

After decryption, my file is correctly decrypted to the following string:

```<code>{
  "ConnectionStrings": {
    "IdentityServer4": "server=(localdb)\\mssqllocaldb;database=IdentityServer4.Quickstart.EntityFramework;trusted_connection=yes"
  }
}
</code>```

I would now like to convert that result to an object, which I attempt to do using the following line of code:

```<code>dynamic result = JsonConvert.DeserializeObject(jsonString);
</code>```

When that line executes, I receive the following error:

```<code>"Unexpected character encountered while parsing value: . Path '', line 0, position 0."
</code>```

答:
It seems there is a Byte Order Mark at the beginning of the string.

To strip the BOM, see answers to this question.

However, it would be better not to include it in the string to begin with.  If you have a byte array that includes a BOM and do:

```<code>var jsonString = Encoding.UTF8.GetString(byteArray);
</code>```

Then the BOM will be included.  But if you read the binary data with a StreamReader then the BOM will be processed and removed:

```<code>var jsonString = new StreamReader(new MemoryStream(byteArray)).ReadToEnd();
</code>```

(You could add using statements to that if you prefer, although MemoryStream doesn't actually need to be disposed.)

Or, stream, decrypt and deserialize all at once along the lines of this answer (for XML) and this one (for simultaneous decompression and deserialization of JSON).

Body:
I am doing encryption/decryption of my appsettings.json file within my ASP.NET application.

After decryption, my file is correctly decrypted to the following string:

{
  "ConnectionStrings": {
    "IdentityServer4": "server=(localdb)\\mssqllocaldb;database=IdentityServer4.Quickstart.EntityFramework;trusted_connection=yes"
  }
}

I would now like to convert that result to an object, which I attempt to do using the following line of code:

dynamic result = JsonConvert.DeserializeObject(jsonString);

When that line executes, I receive the following error:

"Unexpected character encountered while parsing value: . Path '', line 0, position 0."

Body:
It seems there is a Byte Order Mark at the beginning of the string.

To strip the BOM, see answers to this question.

However, it would be better not to include it in the string to begin with.  If you have a byte array that includes a BOM and do:

var jsonString = Encoding.UTF8.GetString(byteArray);

Then the BOM will be included.  But if you read the binary data with a StreamReader then the BOM will be processed and removed:

var jsonString = new StreamReader(new MemoryStream(byteArray)).ReadToEnd();

(You could add using statements to that if you prefer, although MemoryStream doesn't actually need to be disposed.)

Or, stream, decrypt and deserialize all at once along the lines of this answer (for XML) and this one (for simultaneous decompression and deserialization of JSON).


问:
Laravel Form Request Dynamic Fields dissapear on Redirect
I have a form, a button to add one more item to form, and Form Request validation file.
All works fine except one thing:
When user adds one more field (after hitting "+Add doc number") and enters value which is already in the DB:

Validation works fine and redirects user to the same page, but now only one field is present:

QUESTION: how to make the all fields present in pic 1 remain in pic 2?

My code:

Form itself:

```<code><form>
  <div class='inputs'>
    <label>Doc number: </label>
    <input type="text" name="doc_fullnumber[1]" value="{{old('doc_fullnumber.1')}}">
  </div>
  <button id='add_item'>Add doc number</button>
  <input type="submit" value="Submit">
</form>
</code>```

a jquery code which adds one more input if user clicks the "button":

```<code>$(document).ready(function(){
    $('#add_item').on('click', function (event) {
        event.preventDefault();
        var i = 2;
        $new_docnumber = $(
            '<br><br>'+
            '<label>Номер док-та: </label>'+
            '<input type="text" name="doc_fullnumber['+i+']" placeholder="Номер док-та" value="{{old('doc_fullnumber.[i]')}}">');
        $('.inputs').append($new_passenger);
    })
})
</code>```

a working form validation in a Laravel's FormRequest file:

```<code>public function rules()
{
    return [

        'doc_fullnumber' => 'unique:tourists'

    ];
}

public function messages()
{
    return ['doc_fullnumber.unique' => 'Doc number is already in DB!'];
}
</code>```

Appreciate any help folks!

答:
This is normal since original DOM loaded without elements appended by JS, I suggest that you use JQuery(Ajax) instead.

if you still want to use your code, you should use JS to recreate the request parameters, you will need to loop through parameters of the URL request by using key array to create inputs name="key" value="value", I hope that help.

This is the code to get prams:

```<code>var qd = {};
if (location.search)
  location.search.substr(1).split("&").forEach(function(item) {
  var s = item.split("="),
    k = s[0],
    v = s[1] && decodeURIComponent(s[1]);
  (qd[k] = qd[k] || []).push(v)
})
</code>```

Body:
I have a form, a button to add one more item to form, and Form Request validation file.
All works fine except one thing:
When user adds one more field (after hitting "+Add doc number") and enters value which is already in the DB:

Validation works fine and redirects user to the same page, but now only one field is present:

QUESTION: how to make the all fields present in pic 1 remain in pic 2?

My code:

Form itself:

<form>

    Doc number:
    <input type="text" name="doc_fullnumber[1]" value="{{old('doc_fullnumber.1')}}">

  <button id='add_item'>Add doc number</button>
  <input type="submit" value="Submit">
</form>

a jquery code which adds one more input if user clicks the "button":

$(document).ready(function(){
    $('#add_item').on('click', function (event) {
        event.preventDefault();
        var i = 2;
        $new_docnumber = $(
            '

'+
            'Номер док-та: '+
            '<input type="text" name="doc_fullnumber['+i+']" placeholder="Номер док-та" value="{{old('doc_fullnumber.[i]')}}">');
        $('.inputs').append($new_passenger);
    })
})

a working form validation in a Laravel's FormRequest file:

public function rules()
{
    return [

        'doc_fullnumber' => 'unique:tourists'

    ];
}

public function messages()
{
    return ['doc_fullnumber.unique' => 'Doc number is already in DB!'];
}

Appreciate any help folks!

Body:
This is normal since original DOM loaded without elements appended by JS, I suggest that you use JQuery(Ajax) instead.

if you still want to use your code, you should use JS to recreate the request parameters, you will need to loop through parameters of the URL request by using key array to create inputs name="key" value="value", I hope that help.

This is the code to get prams:

var qd = {};
if (location.search)
  location.search.substr(1).split("&").forEach(function(item) {
  var s = item.split("="),
    k = s[0],
    v = s[1] && decodeURIComponent(s[1]);
  (qd[k] = qd[k] || []).push(v)
})


问:
Error in accessing internal sd card file
I am new to Android. I tried to open a file in internal storage.

The file is located in: mnt/sdcard/italy.sqlite. There are many solutions on the web, I tried some, but I am keeping get different errors..

First try:

```<code>String extStore = System.getenv("EXTERNAL_STORAGE");

File spatialDbFile = new File(extStore, "italy.sqlite");
</code>```

I printed System.getenv("EXTERNAL_STORAGE"); , I got:

/sdcard

Second try:

```<code>File spatialDbFile = new File("mnt/sdcard/italy.sqlite");
</code>```

This still doesn't work.

Could someone help me?

答:
You should better check whether you have given permission to open file in internal storage at Manifest file.
it will be like-</p>

```<code>//Here is an example of the manifest file:

<?xml version="1.0" encoding="utf-8"?>

<manifest>

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration />
    <uses-feature />
    <supports-screens />
    <compatible-screens />
    <supports-gl-texture />

    <application>

        <activity>
            <intent-filter>
                <action />
                <category />
                <data />
            </intent-filter>
            <meta-data />
        </activity>

        <activity-alias>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </activity-alias>

        <service>
            <intent-filter> . . . </intent-filter>
            <meta-data/>
        </service>

        <receiver>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </receiver>

        <provider>
            <grant-uri-permission />
            <meta-data />
            <path-permission />
        </provider>

        <uses-library />

    </application>

</manifest>
</code>```

Body:
I am new to Android. I tried to open a file in internal storage.

The file is located in: mnt/sdcard/italy.sqlite. There are many solutions on the web, I tried some, but I am keeping get different errors..

First try:

String extStore = System.getenv("EXTERNAL_STORAGE");

File spatialDbFile = new File(extStore, "italy.sqlite");

I printed System.getenv("EXTERNAL_STORAGE"); , I got:

/sdcard

Second try:

File spatialDbFile = new File("mnt/sdcard/italy.sqlite");

This still doesn't work.

Could someone help me?

Body:
You should better check whether you have given permission to open file in internal storage at Manifest file.
it will be like-

//Here is an example of the manifest file:

<?xml version="1.0" encoding="utf-8"?>

<manifest>

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration />
    <uses-feature />
    <supports-screens />
    <compatible-screens />
    <supports-gl-texture />

    <application>

        <activity>
            <intent-filter>
                <action />
                <category />
                <data />
            </intent-filter>
            <meta-data />
        </activity>

        <activity-alias>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </activity-alias>

        <service>
            <intent-filter> . . . </intent-filter>
            <meta-data/>
        </service>

        <receiver>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </receiver>

        <provider>
            <grant-uri-permission />
            <meta-data />
            <path-permission />
        </provider>

        <uses-library />

    </application>

</manifest>


问:
mp4 files dont work properly on chrome
I have 10 MP4 files which I am embedding in my application. When I open my application in Edge, i am able to play all the 10 files smoothly, but in chrome, they don't work properly. I have to refresh the browser couple of time, to make them work.
Though, they work fine if I open the MP4 link directly on chrome.Any idea why they don't work properly on chrome. I am using Vaadin to build my application

I also noticed, if keep only 6 videos, then they work fine. If I put more than 6, then I start seeing the issue

答: seems to be a known issue stackoverflow.com/questions/25249578</p>

Title: mp4 files dont work properly on chrome


问:
Nhibernate .Net attribute mapping. It is possible to set default value?
It is possible to set a default value for attribute mapping ? Example, if i have this property :

```<code>private string sDoorLength;
[NHibernate.Mapping.Attributes.Property(Column = "door_length")]
public string DoorLength { get { return sDoorLength; } set { sDoorLength = value; } }
</code>```

I want to know if it's possible to add a parameter to NHibernate.Mapping.Attributes.Property for setting a default value. Like [NHibernate.Mapping.Attributes.Property(Column = "door_length", Default="Test")] or something like that.

Thank you !

答:
You could initialize the private field to a default value.</p>

```<code>private string sDoorLength = "Test";
</code>```

Body:
It is possible to set a default value for attribute mapping ? Example, if i have this property :

private string sDoorLength;
[NHibernate.Mapping.Attributes.Property(Column = "door_length")]
public string DoorLength { get { return sDoorLength; } set { sDoorLength = value; } }

I want to know if it's possible to add a parameter to NHibernate.Mapping.Attributes.Property for setting a default value. Like [NHibernate.Mapping.Attributes.Property(Column = "door_length", Default="Test")] or something like that.

Thank you !

Body:
You could initialize the private field to a default value.

private string sDoorLength = "Test";


问:
SignInManager track signIn url Asp.Net Core
I have followed this instructions to develop projects with separate authentication endpoint.
I have 2 separate web-applications. One is a Asp.Net Core + Identity Server 4 authentication endpoint. Another application is a client which is configured to authorize via authentication endpoint. Is there a way I can track what kind of web request does the SignInManager send when the following line of code is being executed?

```<code> await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberLogin, lockoutOnFailure: false);
</code>```

I have used Telerik Fiddler Web Debugger 4 and I haven't seen any requests so far

答:
This does not produce any web traffic. You can check out what that method does over here. But in short, it tells the HttpContext to issue a cookie if sign in is successful.

In other words, it will issue a cookie when that controller method ends. Check out the browser cookies and this will give you an idea of what is going on.

Body:
I have followed this instructions to develop projects with separate authentication endpoint.
I have 2 separate web-applications. One is a Asp.Net Core + Identity Server 4 authentication endpoint. Another application is a client which is configured to authorize via authentication endpoint. Is there a way I can track what kind of web request does the SignInManager send when the following line of code is being executed?

 await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberLogin, lockoutOnFailure: false);

I have used Telerik Fiddler Web Debugger 4 and I haven't seen any requests so far


问:
how can I know the iOS app that I made is 32 bit or not? and how can I change that?
as you know after WWDC all of the apple Developer has lots of problems because we have to submit 64 bit application - I am using swift 3 and Xcode 8.3.2 But my app version is iOS 9.3 and I can test this application on iphone4s so how can I change this app to 64 bit and another question
I have iPhone 4s so this application that I am building will not have permission to run in my iPhone ? and should I sell this phone or I can download 32 bit app in this phone after 2018 ?</p>

答:
To change to 64 bit you should:

Select your project

Select your target

Select Build Settings

Look for Valid Architectures

Set only arm64 as the Valid Architecture


问:
Cassandra automatic schema generator
Firstly, I am new to Cassandra, I came from relational databases. I have used Hibernate API's which made the database related tasks pretty simple. I am using java based drivers from datastax to connect and execute queries. They provided the mapping library which implements JPA. So far so good. I created a model class as follows:

```<code>@Table(keyspace = "webscc", name = "t_data", readConsistency = "QUORUM",
writeConsistency = "QUORUM",caseSensitiveKeyspace = false,
caseSensitiveTable = false)
public class ChartData {
    @PartitionKey
    private UUID    id;
    @ClusteringColumn(0)
    private Date    timeStamp;
    @ClusteringColumn(1)
    private String  controller;
    @Column(name = "value")
    private double  value;
    /** Constructors, getters and setters*/
}
</code>```

Now I want to create a new ChartData object and save it into database. For that, I wanted to implement Mapper.

```<code>Session session = Cluster.builder().addContactPoint(props.getProperty(HOSTNAME)).build()
                         .connect(props.getProperty(KEYSPACE));
MappingManager manager = new MappingManager(session);
Mapper<ChartData> mapper = manager.mapper(ChartData.class);
ChartData chartData = new ChartData("controller",24.44);
mapper.save(chartData);
</code>```

I configured everything, still I could not save ChartData object into  table. The problem is it can not create table automatically, although I configured everything in ChartData via annotations. Did I do something wrong, or should I create all required tables manually. Why this does not create database schema automatically like Hibernate does?

答:
Datastax Driver mapper does not create table automatically

There is a open issue On this : https://datastax-oss.atlassian.net/browse/JAVA-569

You have to first create the table manually.

```<code>CREATE TABLE webscc.t_data(
    id uuid,
    timestamp timestamp,
    controller text,
    value double,
    PRIMARY KEY (id, timestamp, controller)
);
</code>```

Or Use the below code after session initialized

```<code>session.execute("CREATE TABLE IF NOT EXISTS webscc.t_data(\n" +
        "        id uuid,\n" +
        "        timestamp timestamp,\n" +
        "        controller text,\n" +
        "        value double,\n" +
        "        PRIMARY KEY (id, timestamp, controller)\n" +
        "    )");
</code>```

Title: Cassandra automatic schema generator

Body:
Firstly, I am new to Cassandra, I came from relational databases. I have used Hibernate API's which made the database related tasks pretty simple. I am using java based drivers from datastax to connect and execute queries. They provided the mapping library which implements JPA. So far so good. I created a model class as follows:

@Table(keyspace = "webscc", name = "t_data", readConsistency = "QUORUM",
writeConsistency = "QUORUM",caseSensitiveKeyspace = false,
caseSensitiveTable = false)
public class ChartData {
    @PartitionKey
    private UUID    id;
    @ClusteringColumn(0)
    private Date    timeStamp;
    @ClusteringColumn(1)
    private String  controller;
    @Column(name = "value")
    private double  value;
    /** Constructors, getters and setters*/
}

Now I want to create a new ChartData object and save it into database. For that, I wanted to implement Mapper.

Session session = Cluster.builder().addContactPoint(props.getProperty(HOSTNAME)).build()
                         .connect(props.getProperty(KEYSPACE));
MappingManager manager = new MappingManager(session);
Mapper<ChartData> mapper = manager.mapper(ChartData.class);
ChartData chartData = new ChartData("controller",24.44);
mapper.save(chartData);

I configured everything, still I could not save ChartData object into  table. The problem is it can not create table automatically, although I configured everything in ChartData via annotations. Did I do something wrong, or should I create all required tables manually. Why this does not create database schema automatically like Hibernate does?

Body:
Datastax Driver mapper does not create table automatically

There is a open issue On this : https://datastax-oss.atlassian.net/browse/JAVA-569

You have to first create the table manually.

CREATE TABLE webscc.t_data(
    id uuid,
    timestamp timestamp,
    controller text,
    value double,
    PRIMARY KEY (id, timestamp, controller)
);

Or Use the below code after session initialized

session.execute("CREATE TABLE IF NOT EXISTS webscc.t_data(\n" +
        "        id uuid,\n" +
        "        timestamp timestamp,\n" +
        "        controller text,\n" +
        "        value double,\n" +
        "        PRIMARY KEY (id, timestamp, controller)\n" +
        "    )");


问:
Sqlite database file managing in Swift 3 and iOS (copy from local and/or bundle to app)
I'm trying to upload my sqlite database file into an application. I've been learning about the iOS file system, and I'm not completely sure how it works and got lost. This is what I would like to achieve, but not sure how:

I would like to have database on this location my-xcode-project-path/data/foo.sqlite. Now I'm running simulator for first time, and I would like to copy this database into simulator's Document directory.

In case if I had the application already installed, I would skip step 1. and copy database from bundle.

If I tried to run simulator, but don't have file available in bundle, I would like to keep that database.

Thank you in advance!!!

My code is looking like this:

```<code>func prepareDatabaseFile() -> String {
    let fileName: String = "foo.sqlite"

    let filemanager:FileManager = FileManager.default
    let directory = filemanager.urls(for: .documentDirectory, in: .userDomainMask).first!

    let newUrl = directory.appendingPathComponent(fileName)
    let bundleUrl = Bundle.main.resourceURL?.appendingPathComponent(fileName)

    // check bundle
    if filemanager.fileExists(atPath: (bundleUrl?.path)!) {
        print("bundle file exists!")
        return (bundleUrl?.path)! //probably I need to copy from bundle to new app and return new url
    // here check if file already exists on simulator, but not in bundle
    } else if filemanager.fileExists(atPath: (newUrl.path)) {
        print("prebuild file exists!")
        return newUrl.path //no copy is needed
    // finally, if nothing I need to copy local file
    } else {
        //todo copy local file from the path my-xcode-project-path/data/foo.sqlite
        print("todo")
    }

    return fileName
}
</code>```

答:
With @Rob's help, I came to following solution which satisfied my requirement. Previously it was necessary to add sqlite file into xcode project, with proper target.</p>

```<code>func prepareDatabaseFile() -> String {
    let fileName: String = "foo.sqlite"

    let fileManager:FileManager = FileManager.default
    let directory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first!

    let documentUrl= directory.appendingPathComponent(fileName)
    let bundleUrl = Bundle.main.resourceURL?.appendingPathComponent(fileName)

    // here check if file already exists on simulator
    if fileManager.fileExists(atPath: (documentUrl.path)) {
        print("document file exists!")
        return documentUrl.path
    else if fileManager.fileExists(atPath: (bundleUrl?.path)!) {
        print("document file does not exist, copy from bundle!")
        fileManager.copyItem(at:bundleUrl, to:documentUrl)
    }

    return documentUrl.path
}
</code>```

Body:
I'm trying to upload my sqlite database file into an application. I've been learning about the iOS file system, and I'm not completely sure how it works and got lost. This is what I would like to achieve, but not sure how:

I would like to have database on this location my-xcode-project-path/data/foo.sqlite. Now I'm running simulator for first time, and I would like to copy this database into simulator's Document directory.

In case if I had the application already installed, I would skip step 1. and copy database from bundle.

If I tried to run simulator, but don't have file available in bundle, I would like to keep that database.

Thank you in advance!!!

My code is looking like this:

func prepareDatabaseFile() -> String {
    let fileName: String = "foo.sqlite"

    let filemanager:FileManager = FileManager.default
    let directory = filemanager.urls(for: .documentDirectory, in: .userDomainMask).first!

    let newUrl = directory.appendingPathComponent(fileName)
    let bundleUrl = Bundle.main.resourceURL?.appendingPathComponent(fileName)

    // check bundle
    if filemanager.fileExists(atPath: (bundleUrl?.path)!) {
        print("bundle file exists!")
        return (bundleUrl?.path)! //probably I need to copy from bundle to new app and return new url
    // here check if file already exists on simulator, but not in bundle
    } else if filemanager.fileExists(atPath: (newUrl.path)) {
        print("prebuild file exists!")
        return newUrl.path //no copy is needed
    // finally, if nothing I need to copy local file
    } else {
        //todo copy local file from the path my-xcode-project-path/data/foo.sqlite
        print("todo")
    }

    return fileName
}

Body:
With @Rob's help, I came to following solution which satisfied my requirement. Previously it was necessary to add sqlite file into xcode project, with proper target.

func prepareDatabaseFile() -> String {
    let fileName: String = "foo.sqlite"

    let fileManager:FileManager = FileManager.default
    let directory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first!

    let documentUrl= directory.appendingPathComponent(fileName)
    let bundleUrl = Bundle.main.resourceURL?.appendingPathComponent(fileName)

    // here check if file already exists on simulator
    if fileManager.fileExists(atPath: (documentUrl.path)) {
        print("document file exists!")
        return documentUrl.path
    else if fileManager.fileExists(atPath: (bundleUrl?.path)!) {
        print("document file does not exist, copy from bundle!")
        fileManager.copyItem(at:bundleUrl, to:documentUrl)
    }

    return documentUrl.path
}