0

I have a several pages which has the same ul (unordered list) with the same content, bur differents links:

<ul class='actions'>
    <li><a href='...'>1</a></li>
    <li><a href='...'>2</a></li>
    <li><a href='...'>3</a></li>
</ul>

The thing is that I made a jquery function wich according to some parameters will delete or not some of the li elments.

My question is, if I have the same ul with the same class ("actions") in different pages, how can I configure differents parameters in my function.

I guess that I can put some hidden field in the page and get the parameters from there, but I think it is not the best approach..

Do you guys have a better idea?

Thanks

5
  • You can't call the function from the individual pages and pass parameters through? Commented Feb 23, 2012 at 21:20
  • There is too much information missing in this question. Commented Feb 23, 2012 at 21:20
  • i think that might be the answer he is looking for... Commented Feb 23, 2012 at 21:21
  • as mentioned on each new page load surely you could pass these elements into the jquery function on page load so for each page you pass in the require params "function removeme(param1, param2){.."? Commented Feb 23, 2012 at 21:29
  • I can call the function on the page, but I want unobtrusive code it will be almost the same if I pass params when the page load. Commented Feb 24, 2012 at 3:24

4 Answers 4

2

I'd use a second class name on the element that you wish to differentiate.

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

1 Comment

Thanks at first I didn't get your idea but after see how Simon explained it, it was very clear.
1

As Diodeus mentioned placing a not used class name in additon to what you currently have:

  <ul class='actions remove'>
      <li><a href='...'>1</a></li>
      <li><a href='...'>2</a></li>
      <li><a href='...'>3</a></li>
  </ul>

or as your not got an id then you could add an id or a data tag to the

  <ul class='action' id='removeme'>...</ul>

  <ul class='actions remove' data-rem='remove'>...</ul>

Depending what your removing and how

Comments

0

Using the <input type="hidden" value="somevalue" /> is a good approach.

If you don't like it you can still use the new HTML5 data attributes. Those attributes start with data- and it's only limited by your imagination and creativitation.

Example:

<button data-id="100" id="delete-item">.

Here's a good explanation of those attributes: http://html5doctor.com/html5-custom-data-attributes/

Comments

0

If these actions are determined on page load you could use PHP to echo the needed parameter into the jQuery function prior to the page being rendered.

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.