setval using js.JQuery

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

setval using js.JQuery

Ian Martins
I tried switching from the jquery library in haxelib to js.JQuery which is now in the standard library.  the jquery library provides SetVal and SetAttrVal, but I don't see anything equivalent in js.JQuery.  The closest I could find was:

new JQuery("selector").get()[0].setAttributeValue("value", "newval");

instead of

JQuery.Qy("selector").SetVal("newval");

But doing the calls through jquery instead of dom works better for some html forms components.  How is it meant to be done?

-Ian

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: setval using js.JQuery

Kelvin Luck
I think it now follows the jQuery API so it would probably be:

new JQuery('selector').attr('attribute_name', 'new_value');

and

new JQuery('selector').val('new_value');

In jQuery it is normally a setter when you pass a value to set and a getter if not...

Hope it helps,

Kelvin :)


On 26 September 2011 21:42, ian martins <[hidden email]> wrote:
I tried switching from the jquery library in haxelib to js.JQuery which is now in the standard library.  the jquery library provides SetVal and SetAttrVal, but I don't see anything equivalent in js.JQuery.  The closest I could find was:

new JQuery("selector").get()[0].setAttributeValue("value", "newval");

instead of

JQuery.Qy("selector").SetVal("newval");

But doing the calls through jquery instead of dom works better for some html forms components.  How is it meant to be done?

-Ian

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: setval using js.JQuery

Nicolas Cannasse
In reply to this post by Ian Martins
Le 26/09/2011 22:42, ian martins a écrit :

> I tried switching from the jquery library in haxelib to js.JQuery which
> is now in the standard library.  the jquery library provides SetVal and
> SetAttrVal, but I don't see anything equivalent in js.JQuery.  The
> closest I could find was:
>
> new JQuery("selector").get()[0].setAttributeValue("value", "newval");
>
> instead of
>
> JQuery.Qy("selector").SetVal("newval");
>
> But doing the calls through jquery instead of dom works better for some
> html forms components.  How is it meant to be done?

The standard jQuery uses exactly the same api as the native JS jquery,
since it's just a type declaration for it.

You should then be able to do new JQuery("selector").val("blabla")

This is not correctly documented as part of the api since it uses new
@:overload metadata to declare several possibilities for "val"
implementation, which are not listed in the api.

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: setval using js.JQuery

Ian Martins
In reply to this post by Kelvin Luck
oh.  maybe the api is out of date.
thanks.

On Mon, Sep 26, 2011 at 4:57 PM, Kelvin Luck <[hidden email]> wrote:
I think it now follows the jQuery API so it would probably be:

new JQuery('selector').attr('attribute_name', 'new_value');

and

new JQuery('selector').val('new_value');

In jQuery it is normally a setter when you pass a value to set and a getter if not...

Hope it helps,

Kelvin :)


On 26 September 2011 21:42, ian martins <[hidden email]> wrote:
I tried switching from the jquery library in haxelib to js.JQuery which is now in the standard library.  the jquery library provides SetVal and SetAttrVal, but I don't see anything equivalent in js.JQuery.  The closest I could find was:

new JQuery("selector").get()[0].setAttributeValue("value", "newval");

instead of

JQuery.Qy("selector").SetVal("newval");

But doing the calls through jquery instead of dom works better for some html forms components.  How is it meant to be done?

-Ian

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: setval using js.JQuery

Adrian Veith
In reply to this post by Ian Martins
in js.JQuery the setters and getters are overloaded using the new @:overload syntax.

When I wrote the old jquery library there was no possibility to overload functions. Therefore I have chosen to name the setters with Set... To switch your code from the old jquery lib to the new js.JQuery you have to rename your setters and use lowercase:

Val() gets:  val()
SetVal('blah') gets: val('blah')

and so on.

best,

Adrian.

Am 26.09.2011 22:42, schrieb ian martins:
I tried switching from the jquery library in haxelib to js.JQuery which is now in the standard library.  the jquery library provides SetVal and SetAttrVal, but I don't see anything equivalent in js.JQuery.  The closest I could find was:

new JQuery("selector").get()[0].setAttributeValue("value", "newval");

instead of

JQuery.Qy("selector").SetVal("newval");

But doing the calls through jquery instead of dom works better for some html forms components.  How is it meant to be done?

-Ian


This body part will be downloaded on demand.

--
haXe - an open source web programming language
http://haxe.org