Wednesday, August 22, 2012

Re: JSNI troubles (TypeError)

Decorate your JSNI with some "console.log(...." statements. Open up in
your browser your Dev Tools (depends on the browser you are using),
look at the console and narrow down the issue there.

If you provide a simple concise example that allows the issue to be
easily duplicated, I'll be happy to take a look at it here as well.

Best regards,

Alfredo

On Wed, Aug 22, 2012 at 4:36 PM, dhoffer <dhoffer6@gmail.com> wrote:
> I'm trying to write a little JNSI but am having trouble, I get an
> exception with this this message (TypeError): Object expected
>
> When I run this code:
>
> public static native void init(String id) /*-{
>
> var elem = $doc.getElementById(id);
> addEvent(elem, 'drop', droppedHandler);
> addEvent(elem, 'dragover', allowDrop);
>
> function allowDrop(event) {
> if (event.stopPropagation)event.stopPropagation();
> if (event.preventDefault)event.preventDefault();
> return false;
> }
>
> function droppedHandler(event) {
> if (event.preventDefault)event.preventDefault();
> return false;
> }
>
> var addEvent = (function () {
> if (document.addEventListener) {
> return function (el, type, fn) {
> if (el && el.nodeName || el === window) {
> el.addEventListener(type, fn, false);
> } else if (el && el.length) {
> for (var i = 0; i < el.length; i++) {
> addEvent(el[i], type, fn);
> }
> }
> };
> } else {
> return function (el, type, fn) {
> if (el && el.nodeName || el === window) {
> el.attachEvent('on' + type, function () {
> return fn.call(el, window.event);
> });
> } else if (el && el.length) {
> for (var i = 0; i < el.length; i++) {
> addEvent(el[i], type, fn);
> }
> }
> };
> }
> })();
> }-*/;
>
> Where in my extended RichTextArea I set a unique ID on its element
> via:
>
> private final String id = UUID.uuid();
> getElement().setId(id);
>
> I don't think the problem is in the body of the method...i think there
> is something wrong with getting a valid Element to the addEvent()
> method. Also is there a way to debug this somehow so I can see what
> is really happening?
>
> Thanks,
> -Dave
>
> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>



--
Alfredo Quiroga-Villamil

AOL/Yahoo/Gmail/MSN IM: lawwton

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate