callback - writing a Jacada Interaction extension -


i want create "extension" jacada interaction (to extend functionality), in case parse , assign numerical part of serialnumber (a letter, followed digits) numeric global ("system") variable, serialnumeric. lacking structure , syntax make work, including way reference interaction variables within extension.

here failed attempt, lines commented out make innocuous after failing; think removed "return page;" after crashing, whereupon still crashed:

initextensions("serialnumeric", function(app){     app.registerextension("loaded", function(ctx, page) {         // place extension code here         //$('[data-refname="snum"]').val('serialnumber');                 // snum = number(substring(serialnumber,1))     }); }); 

here example of 1 works:

/**  * description: add swiping gestures navigate next/previous pages   */ initextensions("swipe", function(app) {     // swipe gestures (mobile only)     app.registerextension('pagerenderer', function(ctx, page) {         page.swipe(function(evt) {                         (evt.swipestart.coords[0] - evt.swipestop.coords[0] > 0)                   ? app.nextbutton.trigger('click')                 : app.backbutton.trigger('click')         });         return page;     }); }); 

after reading comment below, tried following, unsuccessfully (the modified question variable not written variable). rendered poorly in comment section, putting here:

    initextensions("serialnumeric", function(app){         app.registerextension("loaded", function(ctx, page) {             var sernum = new string($('[data-refname="enter"] input'));             var snumeric = new string(sernum.substr(1));             $('[data-refname="enter"] input').val(snumeric);         });     }); 

i understand when code run: seems logical run when variable assigned. insight ~

in case, extend loaded event. don't have return page extension in working example below.

the page argument contains dom of page have loaded, ctx argument contains data of page in json form. can inspect content of both arguments in browser's inspection tools. chrome. press f12 on windows or shift+ctrl+i on mac.

the selector $('[data-refname="snum"] input') input field question name snum defined in designer. can place value in input field value serialnumber variable.

$('[data-refname="snum"] input').val(serialnumber); 

you can read values in same way.

you can't (at point) access interaction variables in extension, unless place theses variables inside question fields.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -