Languages

Menu
Sites
Language
disableSelection and disableContextMenu

Hello,

I need your help for disable selection and contextMenu on a Web App.

I have a config.js :

$(document).bind("mobileinit", function() {
    console.log("mobileinit");
	$.mobile.tizen.disableSelection(document);
	$.mobile.tizen.disableContextMenu(document);
});

And I load the config.js like that:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <meta name="viewport"  content="width=720, maximum-scale=1, user-scalable=0">
    <meta name="description" content="A Tizen Web UI FW multi-page template generated by Tizen Web IDE"/>

    <title>Something</title>
    
    <script src="tizen-web-ui-fw/latest/js/jquery.js"></script>
    <script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.js"></script>
    <script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw.js"
        	data-framework-theme="tizen-white"></script>
 
  <script type="text/javascript" src="./js/jquery-1.7.1.js"></script>
     <script type="text/javascript" src="./js/config.js"></script>
    <script type="text/javascript" src="./js/jquery.mobile-1.2.0.js"></script>
    <link rel="stylesheet" href="./css/jquery.mobile-1.2.0.css"/> 
    
    [...]
</head>
[...]
</html>

On my console I can read:

js/config.js (2) :mobileinit
js/config.js (3) :TypeError: 'undefined' is not an object

The selection and menuContext isn't disable, do you know why?

Thank you

Responses

14 Replies
Raghu Kona

Hi,

In config.js file, please replace the event 'mobileinit' with either 'pageinit' or 'pagebeforeshow'.

Regards,

Raghu Kona

Benoit JOUANIGO

Thank you for your help, but I have the same problem with 'pageinit'

Raghu Kona

Can you try with the below order while replacing the mobileinit event with pageinit in config.js file.

<script src="tizen-web-ui-fw/latest/js/jquery.js"></script>

<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.js"></script>
<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw.js"
    data-framework-theme="tizen-white"></script>

<script type="text/javascript" src="./js/config.js"></script>
<script type="text/javascript" src="./js/main.js"></script>

Benoit JOUANIGO

Thank you but always the same error: js/config.js (3) :TypeError: 'undefined' is not an object

Marco Buettner

config.js must after jquery mobile ;) mobileinit is a jquery mobile event ;)

Alexander AVSukhov

Hello,

Check-out the docs for binding to the mobileinit event:

http://jquerymobile.com/demos/1.0/docs/api/globalconfig.html

Specifically this bit:

Because the mobileinit event is triggered immediately upon execution, you'll need to bind your event handler before jQuery Mobile is loaded.

<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>
Benoit JOUANIGO

I always have the same problem. On the console I can read this error:  js/config.js (5) :TypeError: 'undefined' is not an object

 

config.js content:

console.log("Enter");

$(document).bind("pageinit", function() {
    console.log("pageinit");
	$.mobile.tizen.disableSelection(document);
	$.mobile.tizen.disableContextMenu(document);
});

 

Marco Buettner

Maybe its to difficult to read this http://demos.jquerymobile.com/1.2.0/docs/api/globalconfig.html and my post above... Once again1

CREATE A CONFIG:JS file and BIND IT AFTER the Tizen Web Framework !

<script src="tizen-web-ui-fw/latest/js/jquery.min.js"></script>
<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.min.js"></script>
<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw.min.js" data-framework-theme="tizen-white"></script>

<script type="text/javascript" src="./js/config.js"></script>
<script type="text/javascript" src="./js/main.js"></script>

The content of the CONFIG.JS is

$(document).bind("mobileinit", function() {
    console.log("mobileinit");
    $.mobile.tizen.disableSelection(document);
	$.mobile.tizen.disableContextMenu(document);
});

 

Marco Buettner

If you use jQuery with jQuery Mobile you have to add config,.js AFTER jquery mobile.js

Benoit JOUANIGO

Hello,

Thank you for your help and sorry for the delay. So now I changed my config.js to : 

$(document).bind("mobileinit", function() {
    console.log("mobileinit");
    $.mobile.tizen.disableSelection(document);
    $.mobile.tizen.disableContextMenu(document);
});

And with your solution I call the file like that:

<script src="tizen-web-ui-fw/latest/js/jquery.js"></script>
<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.js"></script>
<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw.js"
    	data-framework-theme="tizen-white" data-framework-viewport-width="720"></script>

<script type="text/javascript" src="./js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="./js/jquery.mobile-1.2.0.js"></script>
<link rel="stylesheet" href="./css/jquery.mobile-1.2.0.css"/>
    
<script type="text/javascript" src="./js/config.js"></script>
   
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<script type="text/javascript" src="./js/main.js"></script>

And now I haven't any error but on the console I can't read mobileinit .

But in your link http://demos.jquerymobile.com/1.2.0/docs/api/globalconfig.html, we can see, the file must be called between jquery.js and jquery-mobile.js so: 

[...]
<script type="text/javascript" src="./js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="./js/config.js"></script>
<script type="text/javascript" src="./js/jquery.mobile-1.2.0.js"></script>
[...]

And with this second solution on my console, I obtain this:

js/config.js (2) :mobileinit
js/config.js (3) :TypeError: 'undefined' is not an object

 

Thank you

Alexander AVSukhov

Hello,

This error occurred because $.mobile.tizen namespace is not defined when mobileinit event triggered.

I have tried use 

$.mobile.tizen.disableContextMenu(document);

in $(document).bind('pageinit') in main.js and it works fine (prevents the context menu event)

Benoit JOUANIGO

Hello,

I have the same error with your solution (error for $.mobile.tizen.disableSelection(document);) : js/main.js (11) :TypeError: 'undefined' is not an object

and my web app is blocked.

Marco Buettner

If you want I can check your project at home... Email m.buettner@scidev.eu
 

Benoit JOUANIGO

Thank you, I just sent you a mail.