2

I have a DIV that looks like this...utilizing the "data-gauge" attribute.

<div class="uib-justgage gauge no_wrap widget uib_w_6" data-uib="widgets/justgage" data-ver="0" id="uib-justgage-3" data-gauge="{'service method':'none','controller type':'single','data path':'not set','title':'Marry','label':'Marry','value':120,'min':0,'max':200,'hideMinMax':0,'hideValue':0,'hideInnerShadow':1}"
                    data-rpath="null" data-array="not set"></div>

What I would like to do is update a couple of the values via jQuery - namely "value" and "max" to new values.

What would the syntax for that be? I'm new to jQuery and figure it would be something like:

 $.("#uib-justgage-3").something.value=x;
 $.("#uib-justgage-3").something.max=y;

Thanks in advance

3 Answers 3

1

you can do it like this:

$( "#uib-justgage-3" ).data( "foo", 52 );
$( "#uib-justgage-3" ).data( "bar", { myType: "test", count: 40 } );

Then access it like

var foo= $( "#uib-justgage-3" ).data( "foo");
var bar= $( "#uib-justgage-3" ).data( "bar");

Here's a little example, it sets the data, then reads it when you click:

    $("#uib-justgage-3").data("foo", 52);
    $("#uib-justgage-3").data("bar", {
      myType: "test",
      count: 40
    });

    $('#b').click(function() {

      var foo = $("#uib-justgage-3").data("foo");
      var bar = $("#uib-justgage-3").data("bar");

      $('<span>').html("foo: " + foo).appendTo($("#uib-justgage-3"));
      $('<span>').html("<br>bar.myType: " + bar.myType).appendTo($("#uib-justgage-3"));
      $('<span>').html("<br>bar.counte: " + bar.count).appendTo($("#uib-justgage-3"));

    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="uib-justgage-3"></div>
<button id="b">Get data</button>

Sign up to request clarification or add additional context in comments.

Comments

0

You could use either $("#uib-justgage-3").data('gauge') or $("#uib-justgage-3").attr('data-gauge') for reading the attribute

and

$("#uib-justgage-3").data('gauge','new value') or $("#uib-justgage-3").attr('data-gauge','new value') for setting the attribute

Comments

0
$('#uib-justgage').data({'rpath','Hello'});//sets data-rpath = Hello
$('#uib-justgage').data('rpath');//gets the value assigned to 'data-rpath'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.