Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: how to add custom javascript function to server mobile app



Permlink Replies: 1 - Last Post: May 6, 2016 3:09 AM Last Post By: wijnaldum william
eduardo gonzalez

Posts: 1
Registered: 11/20/09
how to add custom javascript function to server mobile app
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 22, 2014 4:12 AM
Hi!

I'm trying to add a custom JS function to my server mobile app with no
success.

The function is the following:

function mydelete(id,item)
{
var list = $('#StorageMList1');
item.parent("li.ui-li").remove();
list.listview('refresh');

var kname=localStorage.key(id);
localStorage.removeItem(kname);

mbtListJSClick();
}

I have created a Client Unit (unit3.js) and added the following line in PHP
OnShowHeader Page event:

echo "<script type=\"text/javascript\"
src=\"unit3.js\"></script>\n";

It works fine in server-side (browser), but not when deploying to mobile.

Where and how do I have to include the 'unit3.js' function?

I have tried adding the next lines in JSPageCreate event with no success:

$.getScript("unit3.js", function()
{

}
);

Any help?

Thanks!

Eduardo G.

wijnaldum william

Posts: 3
Registered: 6/6/16
Re: how to add custom javascript function to server mobile app
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 6, 2016 3:06 AM   in response to: eduardo gonzalez in response to: eduardo gonzalez
When the execute function is called, the item, query, or id value that was passed as the first argument into the script function is used to perform the operation. For an insert, update or query operation, you can modify the item or query before you call execute:

function insert(item, user, request) {
item.scriptComment =
'this was added by a script and will be saved to the database';
request.execute();
}

function update(item, user, request) {
item.scriptComment =
'this was added by a script and will be saved to the database';
request.execute();
}

function read(query, user, request) {
// Only return records for the current user
query.where({ userid: user.userId});
request.execute();
}
Aws Training in Chennai | Informatica Training in Chennai | Hadoop Training in Chennai

Edited by: wijnaldum william on May 6, 2016 3:07 AM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02