plaflamme / gwtquery-ui

Automatically exported from code.google.com/p/gwtquery-ui
0 stars 5 forks source link

Dialog doesn't open, if set autoOpen to false #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Example:

$("#dialogForm" ).as(Ui).dialog(
        Dialog.Options.create()
            .autoOpen(false));
$("#dialogForm").as(Ui).dialog("open");

Dialog doesn't shows up.
I'm trying to figure out why.

Original issue reported on code.google.com by arny...@gmail.com on 15 Aug 2011 at 3:59

GoogleCodeExporter commented 9 years ago
Too bad jQuery UI isn't following any kind of standardized patterns.

I've included another method to run widget methods as a workaround.
  public JavaScriptObject method(String method) {
    return invoke(ui, widgetType, method);
  }

Just below the option() method inside UiWidget.java.

So to run a method, you'd have to use:
$("#dialogForm").as(Ui).dialog().method("open");

-

Let's hope the jQueryUI team will do a better job on the upcoming API rewrite.

Original comment by arny...@gmail.com on 15 Aug 2011 at 5:39

GoogleCodeExporter commented 9 years ago
Try the "Animated Dialog" demo here: 
http://gwtquery-ui.googlecode.com/svn/demos/GwtQueryUi.html

Does the dialog open when you click the button? It does in Chromium 13.

Also, the Dialog class already has an "open" method. You should be able to do 
this:

$("#dialogForm").as(Ui).dialog().open();

Original comment by philippe...@gmail.com on 15 Aug 2011 at 7:47

GoogleCodeExporter commented 9 years ago
Ah, haven't expected real methods there, sorry.
Though it would look more like jQuery.

Nevertheless, like I said jQuery is following kind of chaotic patterns.
For example:
.dialog( "isOpen" )
Returns true if the dialog is currently open.

So this method returns a value.
Can't find it in qwtquery-ui.

I guess we'd need something like: invokeForInt, invokeForBoolean, 
invokeForClass... so it's easier to implement inside DialogPlugin for instance.

What do you think?

Original comment by arny...@gmail.com on 15 Aug 2011 at 8:20

GoogleCodeExporter commented 9 years ago
Well, gwtquery-ui tries to re-implement the functionalities available in 
jQueryUI, but it can't be identical because of the nature of JavaScript.

I made gwtquery-ui more Java-esque (have typesafe methods for example) on 
purpose. The goal is not to have a one to one relationship with jQueryUI's API.

That being said, it would be useful to have gwtquery-ui be more "open ended" 
and allow calling any method on the jQuery instance.

Original comment by philippe...@gmail.com on 15 Aug 2011 at 8:52

GoogleCodeExporter commented 9 years ago
yes, I know.
But it would be much easier to have some prepared invoke methods to be able to 
use them inside upper widget objects, like the ones you're already using 
(invoke).

I'd like to implement the missing isOpen for instance.
There are plenty other methods that would make use of it.

Like your current implementation inside Datepicker:
  public Date getDate() {
    invoke("getDate");
    return null;
  }

seems like there is something missing ;)

Original comment by arny...@gmail.com on 15 Aug 2011 at 9:14

GoogleCodeExporter commented 9 years ago
Oops! :)

Patches welcomed! I'll gladly review patches you submit and merge them when 
appropriate.

Original comment by philippe...@gmail.com on 15 Aug 2011 at 9:44

GoogleCodeExporter commented 9 years ago
ok, I've done some changes and fixes.

Check the diffs file.

Original comment by arny...@gmail.com on 15 Aug 2011 at 11:50

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch. Mind rewriting the invokeFor* methods to only take the 
method argument?

protected int invokeForInt(String method) {
  return invokeForInt(ui, widgetType, method);
}

I'd like to hide the implementation (passing the jQuery instance and using 
widgetType) within UiWidget.

Original comment by philippe...@gmail.com on 16 Aug 2011 at 12:10

GoogleCodeExporter commented 9 years ago
No, it's ok.
You'd have to add more methods with more arguments then.
I've moved some of your invoke implementations to UiWidget.

See Slider:
  public Slider values(int index, JsArrayNumber values) {
    ui = invoke(ui, widgetType, "values", index, values);
    return this;
  }

That's why I changed them to protected.

Original comment by arny...@gmail.com on 16 Aug 2011 at 12:24

GoogleCodeExporter commented 9 years ago
Added isOpen method in r143. Fixed getDate in Datepicker also.

Original comment by philippe...@gmail.com on 16 Aug 2011 at 12:08

GoogleCodeExporter commented 9 years ago
Do you think you could take all changes into count?

For example the Slider.java:
  public Slider value(Number value) {
    invoke("value", value);
    return this;
  }

  public int intValue() {
    return invokeForInt(ui, widgetType, "value");
  }

  public int intValues(int index) {
    return invoke(ui, widgetType, "values", index);
  }

  public Slider values(int index, JsArrayNumber values) {
    invoke(ui, widgetType, "values", index, values);
    return this;
  }

  private native final int invoke(JavaScriptObject ui, String type, String method, int index)
  /*-{
    return ui[type](method, index);
  }-*/;

  private native final JavaScriptObject invoke(JavaScriptObject ui, String type, String method, int index, Object args)
  /*-{
    return ui[type](method, index, args);
  }-*/;

Datepicker.java is still missing:
  public boolean isDisabled() {
    return invokeForBoolean(ui, widgetType, "isDisabled");
  }

take a look at the ones I've attached earlier.
Thanks

Original comment by arny...@gmail.com on 16 Aug 2011 at 1:04

GoogleCodeExporter commented 9 years ago
Done.

Original comment by philippe...@gmail.com on 16 Aug 2011 at 1:44