These are chat archives for canjs/canjs

15th
May 2017
SebastianHanke
@SebastianHanke
May 15 2017 07:50

@SebastianHanke
canjs 2.3, stealjs 1.5 everything with npm, development works fine, page is loading and working, but if i want to build it now with stealjs following error occures when i load the page with steal.production.js

can.$ is not a function
    at eval (clubportal.js:4418)
    at Function.eval (clubportal.js:4419)
    at execute (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at k (steal.production.js:12)
var stealTools = require("steal-tools");

stealTools.build({
    main: "clubportal",
    config: __dirname + "/steal_build_config.js",
}, {
    dest: __dirname + "/dist",
    minify: false,
    debug: false,
    quiet: false,
});

and the configuration script (almost the same as for dev)

steal.config({
    paths: {
        "can/*": "node_modules/can/*.js",
        "jquery": "node_modules/jquery/dist/jquery.js",
        "dragtable": "node_modules/dragtable/jquery.dragtable.js",
        "tablesorter": "node_modules/tablesorter/dist/js/jquery.tablesorter.min.js",
        "magnific-popup": "node_modules/magnific-popup/dist/jquery.magnific-popup.min.js",
        "ddslick": "node_modules/ddslick/dist/jquery.ddslick.min.js",
        "jQuery.print": "node_modules/jQuery.print/jQuery.print.js",
        //use https://github.com/sschadwick/jquery-ui-dist instead of jquery-ui for ES6 import
        "jquery-ui": "node_modules/jquery-ui-dist/jquery-ui.min.js",
        "jquery-number": "lib/jquery.number.min.js",
        "steal-css": "node_modules/steal-css/css.js"
    },
    map: {
        "jquery/jquery": "jquery",
        "steal-css": "steal-css",
        "can/util/util": "can/util/domless/domless"
    },
    meta: {
        "jquery-ui-dist": { "deps": [ "jquery" ] },
        "jquery": {    "exports": "jQuery", "format": "global"    }
    },
    ext: {
        css: "steal-css",
        mustache: "node_modules/can/view/mustache/system",
        stache: "steal-stache"
    },

});

its this part of the resulting bundle.js

/*can/view/elements*/
define('can/view/elements', [
    'can/util/util',
    'can/view/view'
], function (can) {
    var doc = typeof document !== 'undefined' ? document : null;
    var selectsCommentNodes = doc && function () {
        return can.$(document.createComment('~')).length === 1;
    }();

any hint what i could be doing wrong?

Frank Lemanschik
@frank-dspeed
May 15 2017 07:57
@pYr0x bind it to VM
function () { this.myPromis = .... }.bind(VM)
content of clubportal.js @SebastianHanke
then i tell you whats wrong
Frank Lemanschik
@frank-dspeed
May 15 2017 08:03
@pYr0x i think also () => VM.myPromise = ... could work as far as i can think
SebastianHanke
@SebastianHanke
May 15 2017 08:06
@frank-dspeed
// Load all of the plugin dependencies
import can from 'can/can';
import O2F_Config from './config/config';
import O2F_State from './config/state';
import O2F_lng from './config/lng_de';
import './lib/base';
import {
    O2F_CeckValue,
    O2F_CreateQueries,
    O2F_Date,
    O2F_DropDowns,
    O2F_Pixel,
    O2F_ToggleMenu,
    O2F_UserAgent
} from './lib/base';
import Account from 'account/account';
import Header from 'header/header';
import Content from 'content/content';
import Filter from 'filter/filter';
import Footer from 'footer/footer';
import Match from 'match/match';
import Matchday from 'matchday/matchday';
import Season from 'season/season';
import Downloads from 'downloads/downloads';
import Help from 'help/help';
import Partner from 'partner/partner';

window.$ = $;

import 'jquery/jquery';
import 'jquery-ui';
import 'dragtable';
import 'tablesorter';
import 'jQuery.print';
import 'magnific-popup';
import 'ddslick';
import 'jquery-number';


// don't run if rhino
/*if ( steal.isRhino ) return;*/

//init new global state object
window.O2F_State = new O2F_State();

O2F_Config.canFiles.oContent = Content;
O2F_Config.canFiles.oHeader = Header;
O2F_Config.canFiles.oFilter = Filter;
O2F_Config.canFiles.oMatchday = Matchday;
O2F_Config.canFiles.oMatch = Match;
O2F_Config.canFiles.oSeason = Season;
O2F_Config.canFiles.oDownloads = Downloads;
O2F_Config.canFiles.oHelp = Help;
O2F_Config.canFiles.oPartner = Partner;

var routeFilters = can.route.attr();

can.route.ready();

var ClubportalApp = can.Control.extend({
 //lots of code here
});


/**
 * Document Ready Init App.
 *
 */
$(document).ready(function () {
    // Get Information from UserAgent
    O2F_Config.UserAgent = O2F_UserAgent.mode();

    O2F_CreateQueries.gInit();
    var oClubportal = new ClubportalApp();
    can.route.ready(true);
});
Frank Lemanschik
@frank-dspeed
May 15 2017 08:07
why are u doing this window.$ ? assignment?
try to comment that out
then do import $ from 'jquery/jquery'
@SebastianHanke works?
SebastianHanke
@SebastianHanke
May 15 2017 08:11
still not working, checked if dev still working, and it does
Frank Lemanschik
@frank-dspeed
May 15 2017 08:11
what says steal now?
new error?
SebastianHanke
@SebastianHanke
May 15 2017 08:12
steal just bundles fine, no error nothing, but loading the app yields:
steal.production.js:13 TypeError: Error loading "clubportal" at http://local.dev.osp.bundesliga.de/osp/clubportal/dist/clubportal.js
can.$ is not a function
    at eval (clubportal.js:4401)
    at Function.eval (clubportal.js:4402)
    at execute (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at o (steal.production.js:12)
    at k (steal.production.js:12)
    at Object.execute (steal.production.js:12) "TypeError: Error loading "clubportal" at http://local.dev.osp.bundesliga.de/osp/clubportal/dist/clubportal.js
Frank Lemanschik
@frank-dspeed
May 15 2017 08:13
what canjs version are you using
newst?
ah can 2.3 hmm
try this hotfix
// don't run if rhino
add over that line can.$ = $
and try if that fixes it
i am not sure what we are doing there but as a javascript engineer i expect that will work :)
only justin probally knows why this error comes :)
@justinbmeyer look please into that error above it comes only on production loading dev works its kind wirred
SebastianHanke
@SebastianHanke
May 15 2017 08:17
no still same error, and can.$ is still undefined
Frank Lemanschik
@frank-dspeed
May 15 2017 08:18
but how can it be undefined :)
as we defined it now
SebastianHanke
@SebastianHanke
May 15 2017 08:18
hmmm should i do something in stealconfig or anywhere to map/path something for can?
Frank Lemanschik
@frank-dspeed
May 15 2017 08:18
you added it over the rino line right?
because loading order matters
it needs to get assigned after import of $
SebastianHanke
@SebastianHanke
May 15 2017 08:18
// Load all of the plugin dependencies
import can from 'can/can';
import O2F_Config from './config/config';
import O2F_State from './config/state';
import O2F_lng from './config/lng_de';
import './lib/base';
import {
    O2F_CeckValue,
    O2F_CreateQueries,
    O2F_Date,
    O2F_DropDowns,
    O2F_Pixel,
    O2F_ToggleMenu,
    O2F_UserAgent
} from './lib/base';
import Account from 'account/account';
import Header from 'header/header';
import Content from 'content/content';
import Filter from 'filter/filter';
import Footer from 'footer/footer';
import Match from 'match/match';
import Matchday from 'matchday/matchday';
import Season from 'season/season';
import Downloads from 'downloads/downloads';
import Help from 'help/help';
import Partner from 'partner/partner';

import $ from 'jquery/jquery';
import 'jquery-ui';
import 'dragtable';
import 'tablesorter';
import 'jQuery.print';
import 'magnific-popup';
import 'ddslick';
import 'jquery-number';

can.$ = $;
// don't run if rhino
/*if ( steal.isRhino ) return;*/

//init new global state object
window.O2F_State = new O2F_State();

O2F_Config.canFiles.oContent = Content;
O2F_Config.canFiles.oHeader = Header;
O2F_Config.canFiles.oFilter = Filter;
O2F_Config.canFiles.oMatchday = Matchday;
O2F_Config.canFiles.oMatch = Match;
O2F_Config.canFiles.oSeason = Season;
O2F_Config.canFiles.oDownloads = Downloads;
O2F_Config.canFiles.oHelp = Help;
O2F_Config.canFiles.oPartner = Partner;

var routeFilters = can.route.attr();

can.route.ready();
Frank Lemanschik
@frank-dspeed
May 15 2017 08:19
hmmm we need to wait for justin he knows if we can add can-jquery or something
SebastianHanke
@SebastianHanke
May 15 2017 08:20
k, thanks alot @frank-dspeed for your help :smile:
Frank Lemanschik
@frank-dspeed
May 15 2017 08:20
justin is knowing everything :)
you should upgrade
SebastianHanke
@SebastianHanke
May 15 2017 08:21
k, hope the best!
Frank Lemanschik
@frank-dspeed
May 15 2017 08:21
with the new versions i could help you much better
SebastianHanke
@SebastianHanke
May 15 2017 08:21
yeah i know i upgraded from the old JavaScriptMVC Version!! Its already huge improvement
Frank Lemanschik
@frank-dspeed
May 15 2017 08:21
upgrade more
and your problem is gone
:D
SebastianHanke
@SebastianHanke
May 15 2017 08:21
hehe
Frank Lemanschik
@frank-dspeed
May 15 2017 08:21
then use stache
SebastianHanke
@SebastianHanke
May 15 2017 08:22
ok, ill try while i wait
Frank Lemanschik
@frank-dspeed
May 15 2017 08:22
here !
SebastianHanke
@SebastianHanke
May 15 2017 08:24
:smile:

Pre-migration preparation

Before upgrading your project from 2.x to 3.x, make sure your project builds successfully and all the tests pass.

hmmm
Frank Lemanschik
@frank-dspeed
May 15 2017 08:24
this dosn't matter in this case
SebastianHanke
@SebastianHanke
May 15 2017 08:24
ill try anyway
Frank Lemanschik
@frank-dspeed
May 15 2017 08:24
as your build is success full
the error is in club*.js
and moving away from the single global can object is a good starting point for isolating the problem
i think it will be simply gone after that
SebastianHanke
@SebastianHanke
May 15 2017 08:26
:+1:
SebastianHanke
@SebastianHanke
May 15 2017 12:07
ok, im through all migration infos, got rid of all errors, now i got this one Error loading "can-stache/src/intermediate_and_imports"
or should i ask in stealjs gitter ?
Frank Lemanschik
@frank-dspeed
May 15 2017 12:08
did you install can-stache via npm?
SebastianHanke
@SebastianHanke
May 15 2017 12:09
aye
Frank Lemanschik
@frank-dspeed
May 15 2017 12:09
is there not more info ?
about the error
?
maybe you should try out directly donejs
and paste your code in
as kickstarter
npm install -g donejs
cd newfolder
donejs add app
then paste your code into that skeletton
and join the donejs/donejs gitter :)
SebastianHanke
@SebastianHanke
May 15 2017 12:11
hehe
Frank Lemanschik
@frank-dspeed
May 15 2017 12:11
its bundling steal canjs and that
so its a good idea to use that
SebastianHanke
@SebastianHanke
May 15 2017 12:12
hmm maybe ill try
heres the error
steal.js:3090 GET http://local.dev.osp.bundesliga.de/osp/clubportal/can-stache/src/intermediate_and_imports.js 404 (Not Found)
fetchTextFromURL    @    steal.js:3090
(anonymous)    @    steal.js:3283
init    @    steal.js:377
Promise    @    steal.js:365
value    @    steal.js:3282
loader.fetch    @    steal.js:4155
loader.fetch    @    steal.js:5293
loader.fetch    @    steal.js:5394
loader.fetch    @    steal.js:6483
(anonymous)    @    steal.js:1530
tryCatchReject    @    steal.js:1183
runContinuation1    @    steal.js:1142
Fulfilled.when    @    steal.js:930
ContinuationTask.run    @    steal.js:1040
Scheduler._drain    @    steal.js:97
Scheduler.drain    @    steal.js:62
run    @    steal.js:268
characterData (async)        
(anonymous)    @    steal.js:274
Scheduler.run    @    steal.js:87
Scheduler.enqueue    @    steal.js:72
Pending.become    @    steal.js:833
Pending.resolve    @    steal.js:786
promiseResolve    @    steal.js:390
(anonymous)    @    steal.js:3284
load    @    steal.js:3065
xhr.onreadystatechange    @    steal.js:3077
XMLHttpRequest.send (async)        
fetchTextFromURL    @    steal.js:3090
(anonymous)    @    steal.js:3283
init    @    steal.js:377
Promise    @    steal.js:365
value    @    steal.js:3282
loader.fetch    @    steal.js:4155
loader.fetch    @    steal.js:5293
loader.fetch    @    steal.js:5394
loader.fetch    @    steal.js:6483
(anonymous)    @    steal.js:1530
tryCatchReject    @    steal.js:1183
runContinuation1    @    steal.js:1142
Fulfilled.when    @    steal.js:930
ContinuationTask.run    @    steal.js:1040
Scheduler._drain    @    steal.js:97
Scheduler.drain    @    steal.js:62
run    @    steal.js:268
characterData (async)        
(anonymous)    @    steal.js:274
Scheduler.run    @    steal.js:87
Scheduler.enqueue    @    steal.js:72
Pending.become    @    steal.js:833
Pending.resolve    @    steal.js:786
promiseResolve    @    steal.js:390
(anonymous)    @    steal.js:3284
load    @    steal.js:3065
xhr.onreadystatechange    @    steal.js:3077
XMLHttpRequest.send (async)        
fetchTextFromURL    @    steal.js:3090
(anonymous)    @    steal.js:3283
init    @    steal.js:377
Promise    @    steal.js:365
value    @    steal.js:3282
loader.fetch    @    steal.js:4155
loader.fetch    @    steal.js:5293
loader.fetch    @    steal.js:5394
loader.fetch    @    steal.js:6483
(anonymous)    @    steal.js:1530
tryCatchReject    @    steal.js:1183
runContinuation1    @    steal.js:1142
Fulfilled.when    @    steal.js:930
ContinuationTask.run    @    steal.js:1040
Scheduler._drain    @    steal.js:97
Scheduler.drain    @    steal.js:62
run    @    steal.js:268
characterData (async)        
(anonymous)    @    steal.js:274
Scheduler.run    @    steal.js:87
Scheduler.enqueue    @    steal.js:72
Pending.become    @    steal.js:833
Pending.resolve    @    steal.js:786
promiseResolve    @    steal.js:390
(anonymous)    @    steal.js:3284
load    @    steal.js:3065
xhr.onreadystatechange    @    steal.js:3077
XMLHttpRequest.send (async)        
fetchTextFromURL    @    steal.js:3090
(anonymous)    @    steal.js:3283
init    @    steal.js:377
Promise    @    steal.js:365
value    @    steal.js:3282
loader.fetch    @    steal.js:4155
loader.fetch    @    steal.js:5293
loader.fetch    @    steal.js:5394
loader.fetch    @    steal.js:6483
(anonymous)    @    steal.js:1530
tryCatchReject    @    steal.js:1183
runContinuation1    @    steal.js:1142
Fulfilled.when    @    steal.js:930
ContinuationTask.run    @    steal.js:1040
Scheduler._drain    @    steal.js:97
Scheduler.drain    @    steal.js:62
run    @    steal.js:268
characterData (async)        
(anonymous)    @    steal.js:274
Scheduler.run    @    steal.js:87
Scheduler.enqueue    @    steal.js:72
Pending.become    @    steal.js:833
Pending.resolve    @    steal.js:786
promiseResolve    @    steal.js:390
(anonymous)    @    steal.js:3284
load    @    steal.js:3065
xhr.onreadystatechange    @    steal.js:3077
XMLHttpRequest.send (async)        
fetchTextFromURL    @    steal.js:3090
(anonymous)    @    steal.js:3283
init    @    steal.js:377
Promise    @    steal.js:365
value    @    steal.js:3282
loader.fetch    @    steal.js:4155
loader.fetch    @    steal.js:5293
loader.fetch    @    steal.js:5394
loader.fetch    @    steal.js:6483
(anonymous)    @    steal.js:1530
tryCatchReject    @    steal.js:1183
runContinuation1    @    steal.js:1142
Fulfilled.when    @    steal.js:930
ContinuationTask.run    @    steal.js:1040
Scheduler._drain    @    steal.js:97
Scheduler.drain    @    steal.js:62
run    @    steal.js:268
if you are interested
SebastianHanke
@SebastianHanke
May 15 2017 12:13
yes it looks at the wrong source
Frank Lemanschik
@frank-dspeed
May 15 2017 12:13
looks logical for me
did you install can-stache via npm
because then steal should find it
it reads the package.json
did you use --save ?
as you installed it?
SebastianHanke
@SebastianHanke
May 15 2017 12:13
{
  "name": "clubportal",
  "version": "1.0.0",
  "description": "",
  "main": "clubportal.js",
  "loglevel": "verbose",
  "dependencies": {
    "can": "^3.8.1",
    "can-component": "^3.0.7",
    "can-control": "^3.0.10",
    "can-list": "^3.0.5",
    "can-map": "^3.0.7",
    "can-model": "^3.0.0",
    "can-route": "^3.0.10",
    "can-stache": "^3.0.24",
    "ddslick": "^1.0.2",
    "dragtable": "^2.0.12",
    "jQuery.print": "^1.5.1",
    "jquery": "^2.2.4",
    "jquery-ui-dist": "^1.12.1",
    "magnific-popup": "^1.1.0",
    "steal": "^1.5.2",
    "steal-css": "^1.2.4",
    "steal-stache": "^3.0.7",
    "table-dragger": "^1.0.1",
    "tablesorter": "^2.28.8"
  },
  "devDependencies": {
    "can-upgrade": "0.0.3",
    "steal-tools": "^1.3.3"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "builder": "steal-tools",
    "build": "steal-tools build --config steal_build_config.js --main clubportal",
    "live_reload": "steal-tools live-reload --config steal_livereload_config.js --main clubportal"
  },
  "author": "",
  "license": "ISC",
  "npmAlgorithm": "flat",
  "steal": {
    "plugins": [
      "steal-css",
      "steal-stache"
    ],
    "configDependencies": [
      "live-reload"
    ]
  }
}
Frank Lemanschik
@frank-dspeed
May 15 2017 12:15
"main": "clubportal/index.stache!done-autorender",
add that to steal
and do npm install --save done-autorender
your using a index.stache right?
SebastianHanke
@SebastianHanke
May 15 2017 12:16
no just a index.html
with <script type='text/javascript' src='./clubportal/node_modules/steal/steal.js' data-main='clubportal' config-path='steal_dev_config.js' base-url="clubportal"></script>
Frank Lemanschik
@frank-dspeed
May 15 2017 12:17
hmmm i am not familary with that
wait
SebastianHanke
@SebastianHanke
May 15 2017 12:17
i think its from 2014 or somethig, all the beginning of steal and canjs
Frank Lemanschik
@frank-dspeed
May 15 2017 12:18
@matthewp needs to look into that :)
SebastianHanke
@SebastianHanke
May 15 2017 12:19
:smile:
its not my code, this is from a dev that was here before me, that thing was never updated or anything
Matthew Phillips
@matthewp
May 15 2017 12:36
@SebastianHanke I don't know what is in your steal_dev_config.js but I'd get rid of that
you want steal to use the package.json for its configuration (which it will by default)
otherwise you have to manually config every module you use, which is pretty impractical when using npm
SebastianHanke
@SebastianHanke
May 15 2017 12:43
this is my stealconfig
steal.config({
    map: {
        "jquery/jquery" : "jquery", //map paths(jquery see below), so it can be imported as import 'jquery' and load node_module/... etc
        "dragtable": "dragtable",
        "tablesorter": "tablesorter",
        "jquery-ui": "jquery-ui",
        "jQuery.print": "jQuery.print",
        "magnific-popup": "magnific-popup",
        "ddslick": "ddslick",
        "steal-css": "steal-css",
        "steal-stache": "steal-stache"
    },
    paths: {
        "jquery": "node_modules/jquery/dist/jquery.js",
        "dragtable": "node_modules/dragtable/jquery.dragtable.js",
        "tablesorter": "node_modules/tablesorter/dist/js/jquery.tablesorter.min.js",
        "magnific-popup": "node_modules/magnific-popup/dist/jquery.magnific-popup.min.js",
        "ddslick": "node_modules/ddslick/dist/jquery.ddslick.min.js",
        "jQuery.print": "node_modules/jQuery.print/jQuery.print.js",
        //use https://github.com/sschadwick/jquery-ui-dist instead of jquery-ui for ES6 import
        "jquery-ui": "node_modules/jquery-ui-dist/jquery-ui.min.js",
        "table-dragger": "node_modules/table-dragger/dist/table-dragger.min.js",
        "jquery-number": "lib/jquery.number.min.js",
        "steal-css": "node_modules/steal-css/css.js",
        "steal-stache": "node_modules/steal-stache/steal-stache.js",
        "add-bundles": "node_modules/steal-stache/add-bundles.js",
        "intermediate_and_imports": "node_modules/can-stache/src/intermediate_and_imports.js"
    },
    meta : {

    },
    ext: {
        /*js: "js",*/
        css: "steal-css",
        stache: "steal-stache"
    }
})
but if i dont do this, steal wont find all the other jquery plugins etc
Matthew Phillips
@matthewp
May 15 2017 12:47
it should be able to find them automatically, if not you can put that same config in your package.json under the "steal" property
SebastianHanke
@SebastianHanke
May 15 2017 14:15
Ok, seems to work, thank you! @matthewp

but i got instant another question :smile:

html.indexOf is not a function
    at HTMLParser (can-view-parser.js:182)
    at stache (can-stache.js:164)
    at execute (CLive_ticker_content.js:40)
    at doExecute (steal.js:2155)
    at ensureEvaluated (steal.js:2202)
    at ensureEvaluated (steal.js:2186)
    at ensureEvaluated (steal.js:2186)
    at ensureEvaluated (steal.js:2186)
    at doEnsureEvaluated (steal.js:2165)
    at evaluateLoadedModule (steal.js:2140) "TypeError: Error evaluating match/match

i try to render a component in a controller

export default canComponent.extend({
    tag: 'comp-ticker-content',
    view: canStache(TLive_ticker_content),
    viewModel: {
        ticker_items: new canList(),
        last_refresh_time: null,
        error_occurred: false,
        no_live_data: false,
        update_time: null,
        dropdown_list: new canList([
            { 'name': 'Alles', 'value': 'all' },
            { 'name': 'Tore', 'value': 'Goals' },
            { 'name': 'Wechsel', 'value': 'Substitutions' },
            { 'name': 'Karten', 'value': 'Cards' }
        ]),
        dropdown_map: {
            'all': 'Alles',
            'Goals': 'Tore',
            'Substitutions': 'Wechsel',
            'Cards': 'Karten'
        },
the stache is normal, nothing fancy there. Do i have to registerPartial every subComponent ?
because i render a component in component in component :fire: :smile: this is my main component and all components get rendered there and have subcomponents. worked with canjs 2.3 just fine
<div><toggle-filter /></div>
<comp-ticker {(active)}="{activeTab}" ($click)="{activate_content(%element, %viewModel)}"></comp-ticker>
<comp-table {(active)}="{activeTab}" ($click)="{activate_content(%element, %viewModel)}"></comp-table>
<comp-ladder {(active)}="{activeTab}" ($click)="{activate_content(%element, %viewModel)}"></comp-ladder>
{{#if ticker}}<comp-ticker-content>Ticker</comp-ticker-content>{{/if}}
{{#if table}}<comp-table-content>Tabelle</comp-table-content>{{/if}}
{{#if ladder}}<comp-ladder-content>Torjäger</comp-ladder-content>{{/if}}
Matthew Phillips
@matthewp
May 15 2017 14:42
I don't think I follow, you don't seem to be using partials there...
SebastianHanke
@SebastianHanke
May 15 2017 15:25
i just don't understand the error message that i posted first. something with my component.
Kevin Phillips
@phillipskevin
May 15 2017 15:32
I’m not sure if this is the issue but you don’t need { } around the right side of your click handlers
($click)="{activate_content(%element, %viewModel)}"
should be
($click)="activate_content(%element, %viewModel)"
same thing with the {(active)}s
Matthew Phillips
@matthewp
May 15 2017 16:50
@SebastianHanke Yeah, it's hard to tell. I would suggest 2 things
1) Remove stuff until it starts to work. This means remove as much HTML (stache) as you can
If you remove all of the template and it's still broken, start removing stuff from the JS file (imports especially)
2) once you figure out the problem please file an issue in https://github.com/canjs/can-stache about the bad error message.
Regardless if what the issue turns out to be, the error should be more descriptive
Julian
@pYr0x
May 15 2017 18:03
@frank-dspeed unfortunately, no solution is working
anybody knows a solution about this: https://gitter.im/canjs/canjs?at=5917a80900efc2bb3e6525b9
Brad Momberger
@bmomberger-bitovi
May 15 2017 18:05
@pYr0x use a setter on myPromise to also push it into probeunterschung as a property when set on the viewmodel.
Julian
@pYr0x
May 15 2017 18:06
i did. so this is the only solution?
push from parent to child
Brad Momberger
@bmomberger-bitovi
May 15 2017 18:06
Either that or give a reference to the full parent on the child.
Julian
@pYr0x
May 15 2017 18:07
how should i do that. the parent is not created at the time the child is created
VM is not defined
Brad Momberger
@bmomberger-bitovi
May 15 2017 18:08
at init on parent, you should be able to access this.probeunterschungto set props on it.
i.e. parent
don't forget to define that parent reference, though, since that object is typed.
Julian
@pYr0x
May 15 2017 18:10
ok i will try that. thanks
Kevin Phillips
@phillipskevin
May 15 2017 18:14
you could use a value function for probeuntersuchung also
Brad Momberger
@bmomberger-bitovi
May 15 2017 18:14
good point
Kevin Phillips
@phillipskevin
May 15 2017 18:15
probeuntersuchung: {
    value: function() {
        return { myPromise: this.myPromise }; 
    },
    Type: {
      myPromise: ‘any’,
      korrigiert: {
something like that would work too @pYr0x
Julian
@pYr0x
May 15 2017 18:17
ok nice..
like that
thx
Kevin Phillips
@phillipskevin
May 15 2017 18:18
yeah, you’re welcome
Dovid Bleier
@dbleier
May 15 2017 18:34
Hi, just upgraded to canjs@3 and now my model tests are hanging. They hit the fixture but never make it back to the then({}) clause. Using can-connect@1 and can-fixture@1
for fixture have tried both
fixture('POST /cms/save/1', {created: true});
and
      '/cms/save/1': (req, res) => {
        //store.create(req, res)
        return {
            data: [
                {created: true}
            ]
        };
    },
here is the test
QUnit.test('Test save/create', (assert) => {
  var done = assert.async(),
  sign = new Sign({user: 'tester', path:'tester/test3'});
  sign.save().then((res) =>{
      QUnit.equal(res.created, true, 'sign created');
      done();
  });
});
and model is
import CanMap from 'can-map';
import CanList from 'can-list';
import superMap from 'can-connect/can/super-map/';
import 'can-map-define';
import tag from 'can-connect/can/tag/';

export const Sign = CanMap.extend({
  define: {}
});

Sign.List = CanList.extend({
  Map: Sign
}, {});

export const signConnection = superMap({
  url:  {
      getListData: 'GET /cms/signlist/1',
      getData: 'GET /cms/get/1?mid={id}',
    createData: 'POST /cms/save/1',
    updateData: 'POST /cms/save/1?mid={id}',
    destroyData: '/cms/delete/1?type=sign&mid={id}&user={user}'
  },
  idProp: 'id',
  Map: Sign,
  List: Sign.List,
  name: 'sign'
});

tag('sign-model', signConnection);

export default Sign;
Dovid Bleier
@dbleier
May 15 2017 18:56
anyone have any ideas?
Matthew Phillips
@matthewp
May 15 2017 18:56
i would add an error handler for your promise
its possible that will give you more info
Dovid Bleier
@dbleier
May 15 2017 18:57
oh good idea, will do that and report back
Brad Momberger
@bmomberger-bitovi
May 15 2017 18:57
Shouldn't your fixture be calling res()with the response data instead of returning it?
Dovid Bleier
@dbleier
May 15 2017 18:58
I tried that too and it didn't work, so I saw this approach in the can-fixture docs
@matthewp good call, here is the error
ERROR TypeError: Cannot read property 'id' of undefined
    at Behavior.id (http://10.0.0.1:9001/node_modules/can-connect/base/base.js:97:22)
    at eval (http://10.0.0.1:9001/node_modules/can-connect/data/localstorage-cache/localstorage-cache.js:163:19)
    at Array.map (native)
    at Behavior.updateSet (http://10.0.0.1:9001/node_modules/can-connect/data/localstorage-cache/localstorage-cache.js:162:18)
    at Behavior.eval (http://10.0.0.1:9001/node_modules/can-connect/data/localstorage-cache/localstorage-cache.js:433:11)
    at loop (http://10.0.0.1:9001/node_modules/can-connect/data/localstorage-cache/localstorage-cache.js:195:15)
    at Behavior._eachSet (http://10.0.0.1:9001/node_modules/can-connect/data/localstorage-cache/localstorage-cache.js:208:18)
    at Behavior.createData (http://10.0.0.1:9001/node_modules/can-connect/data/localstorage-cache/localstorage-cache.js:431:9)
    at Behavior.behavior.(anonymous function) [as createdData] (http://10.0.0.1:9001/node_modules/can-connect/data/callbacks-cache/callbacks-cache.js:60:39)
    at eval (http://10.0.0.1:9001/node_modules/can-connect/data/callbacks/callbacks.js:103:32)
Morgan Heimbeck
@Xitstrategies
May 15 2017 19:00
Ya, pretty sure it is suppose to call res(....)
Dovid Bleier
@dbleier
May 15 2017 19:01
this was my original fixture that was not working
      '/cms/save/1': (req, res) => {
        //store.create(req, res)
        res({
            created: true
        });
    },
Brad Momberger
@bmomberger-bitovi
May 15 2017 19:01
always wrap fixtures responses in {data: ... ]
so:
      '/cms/save/1': (req, res) => {
        //store.create(req, res)
        res({ data: {
            created: true
        }});
    },
That's probably what's been undefined all this time.
Dovid Bleier
@dbleier
May 15 2017 19:03
tried that now, still getting the error
Brad Momberger
@bmomberger-bitovi
May 15 2017 19:03
clear your local storage
Dovid Bleier
@dbleier
May 15 2017 19:07
now I am confused. I cleared localStorage and then it returned to my then() clause. Yay! However was failing the test, since res.created was undefined because the created field is now in data. So, I updated assert to look at res.data.created and now it's throwing the same error again. LocalStorage is still empty.
Brad Momberger
@bmomberger-bitovi
May 15 2017 19:10
you're sure that res in your save callback had a data property?
Dovid Bleier
@dbleier
May 15 2017 19:10
also tried adding an id prop to response data
you mean this?
  sign.save().then((res) =>{
      QUnit.equal(res.data.created, true, 'sign created');
      done();
  })
Brad Momberger
@bmomberger-bitovi
May 15 2017 19:11
yes
Dovid Bleier
@dbleier
May 15 2017 19:11
yes
there it is
Brad Momberger
@bmomberger-bitovi
May 15 2017 19:13
That's not what should happen. the connection should unpack the data object into a Map instance. :-/
unless you specify parseInstanceProp
Dovid Bleier
@dbleier
May 15 2017 19:19
no, I am not
Viktor Busko
@Lighttree
May 15 2017 19:40

Guys, if i have this kind of helper:

{{i18n 'my_text_propery {0} and {1}' 0=propFromScope 1='another prop as string'}}

It should replace tokens in first string with values from hash. But if I use some variable like propFromScope it passes compute. Is there a way to pass string value instead of compute ? (it must be a string)

Brad Momberger
@bmomberger-bitovi
May 15 2017 19:42
Try using Call syntax instead of Helper syntax:
{{i18n ('my_text_propery {0} and {1}', 0=propFromScope, 1='another prop as string')}}
(The only difference is parentheses surrounding the arguments and commas separating them)
A Call expression shouldn't pass computes to functions it calls unless specifically asked for (by prefixing with ~)
Viktor Busko
@Lighttree
May 15 2017 20:11
Thanks, this works, just checked. Sad part is that this syntax appeared in later version of can.js than I can use. :D
Brad Momberger
@bmomberger-bitovi
May 15 2017 20:12
In that case you'll have to just resolve your computes in your helper. Sorry to hear upgrade is not currently an option.
Viktor Busko
@Lighttree
May 15 2017 20:13
Yeah, thanks anyway.
Julian
@pYr0x
May 15 2017 20:24
also a simpleHelper will not pass computes to the helper
Chasen Le Hara
@chasenlehara
May 15 2017 20:41
Question: should can-view-callback attrs work if they are defined after the component they’re used in but before the attr is used?
…because the component isn’t rendered until after the attr callback is defined.
It works if I move the attr callback definition first, but I’m wondering if that’s required or if the current behavior is a bug.
Brad Momberger
@bmomberger-bitovi
May 15 2017 20:50
Intuitively they should, but as currently implemented they don't.
I don't think it's ever been specified in the docs, but I find it to be a desirable improvement (the compile stache -> define attr callback -> render stache flow) and if you do too, please file an issue.
Chasen Le Hara
@chasenlehara
May 15 2017 20:56
Yeah, I was in the process of filing an issue and was hoping someone could confirm whether I’m asking for a bug to be fixed or if this is an enhancement request. :P
Chasen Le Hara
@chasenlehara
May 15 2017 21:03
Filed an issue: canjs/can-view-callbacks#43
Julian
@pYr0x
May 15 2017 23:11
how can i check if a can-connect instance is new in the defineList
with {{this.isNew()}} i get no result
const DefineMap = require("can-define/map/");
const DefineList = require("can-define/list/");
const set = require("can-set");
const baseMap = require("can-connect/can/base-map/");
const superMap = require("can-connect/can/super-map/");

const Pruefbericht = DefineMap.extend({
  seal: false
}, {
  "pruefbericht_id": "any"
});

const algebra = new set.Algebra(
  set.props.id("pruefbericht_id"),
  set.props.sort("orderBy")
);

Pruefbericht.List = DefineList.extend({
  "#": Pruefbericht
});

Pruefbericht.connection = baseMap({
  url: window.Config.baseUrl + "/api/pruefbericht",
  Map: Pruefbericht,
  name: "pruefbericht",
  algebra
});

module.exports = Pruefbericht;
in some other code i said const p = new Pruefbericht({}) the new instance gets added to the list but is there a way to check that this new row i a new one