Search Results

Search found 9 results on 1 pages for 'kuswantin'.

Page 1/1 | 1 

  • Toggle row visibility one at a time

    - by kuswantin
    I have a couple of tables with similar structures like this: <table> <tbody> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> ..etc --- The fake button is added here <div class="addrow">Add another</div> </tbody> </table> Since this is a long list, I have a need to toggle the rows one at a time. I just need to show the first row, of course, the rest should be toggled. The action is when I click a dynamic fake button, it will show row no. 2, and clicking again will show another next row. This is what I have done so far: $("table#field_fruit_values tr.draggable").not(':first').hide(); $("table#field_vegetables_values tr.draggable").not(':first').hide(); $("body.form table.content-multiple-table tbody").append('<div class="addrow">Add</div>'); $(".addrow").click(function() { var hiddenRow = $(this).prev('tr.draggable'); $(this).prev(hiddenRow + 1).show(); //if (hiddenRow + ':last').length) { // <= silly logic // $(this).hide(); //} }); The button only works for one row. I must have done something wrong :) When the final is reached, I also want the button to disappear. Sorry if this question sound silly. Any help would be very much appreciated. Thanks.

    Read the article

  • Insert text into a div from a poput form and rewrite the inserted text with javascript

    - by kuswantin
    So I read some related questions here before I asked, but can't find the answer to my problem. Hope some javascript master here can find this and bring the light to me. I created another button for nicEdit, a video button and wanted to insert some formatted text into the editor DIV (note: nicEdit has inline DIV, no iframe, no textarea). This is my button, recreated from the image button: var nicVideoOptions = { buttons : { 'video' : {name : __('Insert Video'), type : 'nicEditorVideoButton'} //, tags : ['VIDEO:'] }, iconFiles : {'video' : '../movie.png'} }; var nicEditorVideoButton = nicEditorAdvancedButton.extend({ addPane : function() { this.vi = this.ne.selectedInstance.selElm().parentTag('A'); this.addForm({ '' : {type : 'title', txt : 'Insert Video URL'}, 'href' : {type : 'text', txt : 'URL', 'value' : 'http://', style : {width: '150px'}} },this.vi); }, submit : function(e) { var vidVal = this.inputs['href'].value; if(vidVal == "" || vidVal == "http://") { alert("Enter the video url"); return false; } this.removePane(); if(!this.vi) { var tmp = 'javascript:nicVidTemp();'; this.ne.nicCommand("insertVideo",tmp); // still nothing works //this.vi = this.findElm('VIDEO:','href',tmp); //this.vi = this.setContent('[video:' + this.inputs['href'].value + ']'); //nicEditors.findEditor('edit-comment').setContent('<strong>Some HTML</strong> here'); //this.vi = this.setContent('<strong>Some HTML</strong> here'); insertAtCaret(this.ne.selectedInstance, vidVal); } if(this.vi) { // still nothing works //this.vi.setAttributes({ //vidVal : this.inputs['href'].value //}); //this.vi = this.setContent('[video:' + this.inputs['href'].value + ']'); //this.vi = this.setContent('<strong>Some HTML</strong> here'); } } }); nicEditors.registerPlugin(nicPlugin,nicVideoOptions); The button is there, the form poput like the image button, so it's okay. But can't insert the text into the DIV. The final output will be taken from this: ('[video:' + this.inputs['href'].value + ']') and displayed in the editor DIV as is: [video:http//some.com/video-url] As you see, I am blindly touching everything :) And this insertion is taken from: http://www.scottklarr.com/topic/425/how-to-insert-text-into-a-textarea-where-the-cursor-is/ function insertAtCaret(areaId,text) { var txtarea = document.getElementById(areaId); var scrollPos = txtarea.scrollTop; var strPos = 0; var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) ); if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); strPos = range.text.length; } else if (br == "ff") strPos = txtarea.selectionStart; var front = (txtarea.value).substring(0,strPos); var back = (txtarea.value).substring(strPos,txtarea.value.length); txtarea.value=front+text+back; strPos = strPos + text.length; if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); range.moveStart ('character', strPos); range.moveEnd ('character', 0); range.select(); } else if (br == "ff") { txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus(); } txtarea.scrollTop = scrollPos; } The flow: I click the button, a form popouts, fill the input text box, hit the query button and the text should appear in the editor DIV. I hope I can make myself clear. Any help would be very much appreaciated Thanks

    Read the article

  • Count total children divs inside a container

    - by kuswantin
    I want to count the total divs inside a container and toggle their visibilities with structure like this. Please also note that the div.content may also reside inside another nested or even nested-nested containers. That's why I handle it with jquery to add div.topmost for each topmost parent container: <div id="parent"> <div class="counter">There are 3 div.contents inside the container below</div> <div class="container"> <div class="content"> 1 </div> <div class="container"> <!--container inside container --> <div class="content"> 2 </div> <div class="content"> 3 </div> </div> </div> <div class="counter">There are 5 div.contents inside the container below</div> <div class="container"> <div class="content"> 1 </div> <div class="content"> 2 </div> <div class="content"> 3 </div> <div class="content"> 4 </div> <div class="content"> 5 </div> </div> </div> And the jquery: // only grab the top most container $('#parent > .container').addClass('topmost'); var topMost = $(".topmost"); var totContent = topMost.children('.content').size(); if (topMost.length > 0) { topMost.before('<div class="toggle">There are ' + totContent + ' div.contents inside the container below</div>'); } topMost.hide(); $('#parent > .counter').click(function() { $(this).next('.topmost').toggle(); //alert(totContent); return false; }); But I can't make it work to loop for each div.counter. The counter always shows all div.content. So placing the each function is suspected to be the problem. Any hep would be very much appreciated. Thanks

    Read the article

  • Add delay and focus for a dead simple accordion jquery

    - by kuswantin
    I found the code somewhere in the world, and due to its dead simple nature, I found some things in need to fix, like when hovering the trigger, the content is jumping up down before it settled. I have tried to change the trigger from the title of the accordion block to the whole accordion block to no use. I need help to add a delay and only do the accordion when the cursor is focus in the block. I have corrected my css to make sure the block is covering the hidden part as well when toggled. Here is my latest modified code: var acTrig = ".accordion .title"; $(acTrig).hover(function() { $(".accordion .content").slideUp("normal"); $(this).next(".content").slideDown("normal"); }); $(acTrig).next(".content").hide(); $(acTrig).next(".content").eq(0).css('display', 'block'); This is the HTML: <div class="accordion clearfix"> <div class="title">some Title 1</div> <div class="content"> some content blah </div> </div> <div class="accordion clearfix"> <div class="title">some Title 2</div> <div class="content"> some content blah </div> </div> <div class="accordion clearfix"> <div class="title">some Title 3</div> <div class="content"> some content blah </div> </div> I think I need a way to stop event bubbling somewhere around the code, but can't get it right. Any help would be very much appreciated. Thanks as always.

    Read the article

  • Hide table rows if Cookie is there

    - by kuswantin
    Based on my previous question here and here, I found that I can set a cookie with javascript. I want to combine it with jquery to have a cookie state set for toggled table rows. I want to keep the hidden rows hidden upon reload. Here is what I have achieved so far: // Load cookies if any if(readCookie('togState')) { $('table#toggle tr.' + readCookie('togState')).hide(); } $(function() { $('table#toggle tr.container').click(function() { var idTog = $(this).attr('id'); $(this).toggleClass('off').nextAll('.' + idTog).toggle(); setCookie('togState', idTog, 30); alert('Cookies: ' + readCookie('togState')); }); }); As you can see the cookie is read, but is not set upon browser refresh. What am I doing wrong? What I want is hide any toggled rows (having their classes equal to their parent's container ID), if the parent container is clicked, and so the cookie is set. Any help would be very much appreciated. Thanks.

    Read the article

  • Toggle two divs and classes

    - by kuswantin
    I have two links with classes (login-form and register-form) relevant to their target forms ID, they want to toggle. I have also a predefined 'slideToggle' function to toggle better. This is what I have tried so far: $('#userbar a').click(function() { var c = $(this).attr('class'); $('#userbar a').removeClass('active'); $(this).toggleClass('active'); $('#register-form,#login-form').hide(); //bad, causing flashy $('#' + c).slideToggle('slow'); return false; }); With this I have trouble with the flashy window, and to correctly toggle the active classes when another link is clicked, the other link should not have active class anymore. Additional problem is the link is dead on serial clicks. I have another try, longer one: $('#userbar a').click(function() { var c = $(this).attr('class'); switch (c) { case 'login-form': $('#' + c).slideToggle('slow'); $(this).toggleClass('active'); $('#register-form').hide(); break; case 'register-form': $('#' + c).slideToggle('slow'); $(this).toggleClass('active'); $('#login-form').hide(); break; } return false; }); This one is worse than the first :( Any suggestion to correct the behavior? What I want is when a link with class login-form is click, so toggle the form with ID login-form, and hide the register-form if open. Any help would be very much appreciated. Thanks.

    Read the article

  • Toggle table row siblings

    - by kuswantin
    I have a table structured like this: <table> <tr id="id1" class="parent"></tr> <tr class="id1"></tr> <tr class="id1"></tr> <tr class="id1"></tr> <tr class="id1"></tr> <tr id="id2" class="parent"></tr> <tr class="id2"></tr> <tr class="id2"></tr> <tr class="id2"></tr> <tr class="id2"></tr> .....etc </table> As you can see child classes are coresponding to their parent id. Now I want to toggle all the rows which have class names equal to their parent row id whenever parent row is clicked. I have tried this, perhaps stupid try:) and can't seem to get this working: $('tr.parent').click(function() { //alert('yay'); var tog = $(this).attr('id'); $(this).siblings().hasClass(tog).slideToggle(); return false; }); Thanks.

    Read the article

  • Clone elements and load previously loaded scripts

    - by kuswantin
    Hi, I am using clone() to move certain elements into another place in the DOM, but had trouble due to the fact that the scripts previously rendered was not available anymore when called from the cloned elements. So I think I need to call them again, but one by one will be a PITA. Perhaps getScript will do, but I have no idea to call more than one. Any help would be very much appreciated. Thanks

    Read the article

  • Set attribute disabled to options NOT containing a certain string

    - by kuswantin
    I know this should be easier if I could only use optgroups. But I am trying to avoid hacking core of my CMS, so jQuery should come to rescue again, hopefully. I have a select with options in a hierarchy sometimes, and I want to put attributes disabled to any of options containing text NOT starting with a dash. I want to code like: Set disabled attributes to selectors with options text NOT starting with a dash ("-"). <select id="options"> <option value="" selected="selected">- Please choose -</option> <option value="1">Parent1</option> <option value="2">-child1</option> <option value="3">-child2</option> <option value="4">-child3</option> <option value="5">-child4</option> <option value="6">Parent2</option> <option value="7">-child5</option> <option value="8">-child6</option> <option value="9">-child7</option> <option value="10">-child8</option> </select> The closest solution is here http://stackoverflow.com/questions/2012299/contain-start-by, $.extend($.expr[':'], { startsWith: function(elem,match) { return (elem.textContent || elem.innerText || "").indexOf(match[3]) == 0; } }); But I can't seem to do it right this far. Any help would be very much appreciated. Thank you very much.

    Read the article

1